Skip to content

Commit

Permalink
使用新的写法
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Feb 22, 2014
1 parent 9b34170 commit 5369b4c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- 简易的blizzard.lua,若需要完整的blizzard.lua,可以使用jass2lua工具,自行转换。

local CJ = jass
local CJ = require "jass.common"
local BJ = {}

BJ.bj_MAX_PLAYER_SLOTS = 16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local CJ = jass
local CJ = require "jass.common"
local BJ = require "blizzard.lua"

local trig = CJ.CreateTrigger()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
local runtime = require "jass.runtime"

-- 开启一个调试窗口,用于显示调试信息,正式的版本请去掉。
-- 注:若在本文件内有语法错误,这行代码就不会被执行,语法错误也无法显示。所以
-- 需要在一切都开始前,执行它;并确保本文件内没有错误。
jass_ext.runtime.console = true
runtime.console = true

-- 注册错误回调函数,当执行lua发生错误时,会调用此函数。
-- 注:注册此函数会略微增加运行时消耗(即使没有发生错误)。
function jass_ext.runtime.error_handle(msg)
function runtime.error_handle(msg)
print("---------------------------------------")
print(" LUA ERROR ")
print("---------------------------------------")
Expand All @@ -15,7 +17,7 @@ function jass_ext.runtime.error_handle(msg)
end

--
-- 设定调用cj函数返回的handle的type。(默认值为1)
-- 设定调用cj函数返回的handle的type。(默认值为2)
-- 安全性依次递增,同时效率也会依次下降。
-- 0: 返回number。
---- 没有任何额外的安全性控制。
Expand All @@ -28,9 +30,15 @@ end
---- lua持有handle时会增加handle的引用计数,并在__gc元方法中释放handle。
---- 0不再能被隐式转换为nil,对应jass里的null请使用nil。
--
jass_ext.runtime.handle_level = 1
runtime.handle_level = 2

-- 开启此项(默认开启),调用jass.xxx/japi.xxx发生崩溃时,会生产一个lua错误,并忽略这个崩溃。
-- 你可以注册jass_ext.runtime.error_handle,来获得这个错误。
-- 注:开启此项会略微增加运行时消耗(即使没有发生错误)。
jass_ext.runtime.catch_crash = true
runtime.catch_crash = true

-- 此项默认为开启。common.j中包含sleep操作的函数有4个,TriggerSleepAction/TriggerSyncReady
-- /TriggerWaitForSound/SyncSelections。当此项为false时,lua引擎会忽略这4个函数的调用,并给
-- 予运行时警告。当此项为true时,这4个函数将会得到正确的执行。
-- 注:开启此项会增加运行时消耗,即使你没有使用这4个函数。
runtime.sleep = true
14 changes: 7 additions & 7 deletions Development/Editor/Component/plugin/YDTrigger/YDTrigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
# include <YDTrigger/Common/switch.h>
# define YDWEGetObjectProperty(object_type, object_id, property) \
YDTRIGGER_COMMON_SWITCH(YDWE_GET_OBJECT_PROPERTY_ ## object_type, ( \
EXExecuteScript("slk.ability[" + I2S(object_id) + "]." + property), \
EXExecuteScript("slk.buff[" + I2S(object_id) + "]." + property), \
EXExecuteScript("slk.unit[" + I2S(object_id) + "]." + property), \
EXExecuteScript("slk.item[" + I2S(object_id) + "]." + property), \
EXExecuteScript("slk.upgrade[" + I2S(object_id) + "]." + property), \
EXExecuteScript("slk.doodad[" + I2S(object_id) + "]." + property), \
EXExecuteScript("slk.destructable[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').ability[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').buff[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').unit[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').item[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').upgrade[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').doodad[" + I2S(object_id) + "]." + property), \
EXExecuteScript("(require'jass.slk').destructable[" + I2S(object_id) + "]." + property), \
))
# define YDWEGetObjectPropertyInteger(type, id, prop) S2I(YDWEGetObjectProperty(type, id, prop))
# define YDWEGetObjectPropertyReal(type, id, prop) S2R(YDWEGetObjectProperty(type, id, prop))
Expand Down

0 comments on commit 5369b4c

Please sign in to comment.