找回密码
 点一下
查看: 4289|回复: 17

关于call code... 还有Condition....

[复制链接]
发表于 2007-12-6 04:43:57 | 显示全部楼层 |阅读模式
下面的代码
[codes=jass]
function test takes code c returns nothing
    call c
endfunction
[/codes]

为什么会让WE崩溃?
用JassCraft编译
提示第三行语法错误....


另外,有篇文章讲老狼把Action都写进了Condition,为什么那篇文章让自己去找教程...我找了很久找不到...哪位高手能告诉我为啥要用Condition替代Action?是不是没有等待事件的都写在Condition里好?

谢谢!!
发表于 2007-12-6 10:09:59 | 显示全部楼层
try it like this~~

call TimerStart(udg_tm,0.00,false,c)



至于为何要用condition代替action~~是因为action比condition执行效率低~~
回复

使用道具 举报

发表于 2007-12-6 11:29:01 | 显示全部楼层
ExecuteFunc把。。
回复

使用道具 举报

发表于 2007-12-6 11:38:31 | 显示全部楼层
ExecuteFunc要求函数名作为参数~~明显麻烦得多~~
回复

使用道具 举报

发表于 2007-12-6 12:14:03 | 显示全部楼层
ExecuteFunc效率更低-。-
没必要的时候一般不用
回复

使用道具 举报

发表于 2007-12-6 17:31:57 | 显示全部楼层
主要是这东西可以用字符串作为参数
回复

使用道具 举报

发表于 2007-12-6 17:38:18 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

发表于 2007-12-6 20:00:16 | 显示全部楼层
崩溃的原因不知道,可能这样容易出现死循环所以干脆让它崩掉吧。
回复

使用道具 举报

发表于 2007-12-7 09:58:23 | 显示全部楼层
你也别瞎猜了~~call后面根本不能跟变量而已~~它只能跟一个明文函数~~
回复

使用道具 举报

发表于 2007-12-7 11:21:08 | 显示全部楼层
而且code不能做数组,不能用c2i
要变量记录只能记录string,然后用ExecuteFunc运行
回复

使用道具 举报

发表于 2007-12-7 12:37:08 | 显示全部楼层
引用第9楼Red_Wolf于2007-12-07 11:21发表的  :
而且code不能做数组,不能用c2i
要变量记录只能记录string,然后用ExecuteFunc运行
所言差矣!!!
[codes=jass]
//! import zhuzhu.j
globals
    integer array test
endglobals
function C2I takes code c returns integer
    return c
    return 0
endfunction

function I2C takes integer i returns code
    return i
    return null
endfunction

function test1 takes nothing returns nothing
    call Message("test1")
endfunction

function test2 takes nothing returns nothing
    call Message("test2")
endfunction

function test3 takes nothing returns nothing
    call Message("test3")
endfunction



//trigger     runs
function TrigZhuzhuActions takes nothing returns nothing
    local integer i=S2I(GetEventPlayerChatString())
    if(i<0 or i>3) then
        return
    endif
    call TimerRun(I2C(test),0,false)
endfunction
function InitTrigZhuzhu takes nothing returns nothing
    local trigger Zhuzhu = CreateTrigger(  )

    set test[0]=0
    set test[1]=C2I(function test1)
    set test[2]=C2I(function test2)
    set test[3]=C2I(function test3)

    call TriggerRegisterPlayerChatEvent( Zhuzhu, Player(0), "", true )
    call TriggerAddAction(Zhuzhu, function TrigZhuzhuActions )
endfunction

[/codes]

注:  RunTimer出自zhuzhu.j
作用:  创建一个Timer,并运行里面的函数.
回复

使用道具 举报

发表于 2007-12-7 12:45:24 | 显示全部楼层
这里面我用Timer,但是Timer并不好.

ExecuteFunc开启新线程,并保存原触发信息,但是速度较慢,立即执行,调用函数将等待被调函数返回.
Timer也是开启新线程,损失原触发信息,速度未知. 被调函数在调用函数返回后执行.
TriggerEvaluate,不开启新线程,不能用TriggerSleep,速度较慢,保存原触发信息,立即执行,调用函数将等待被调函数返回.
TriggerExecute,开启新线程,速度最快,保存原触发信息,但损失了GetTriggeringTrigger()信息.  立即执行,调用函数将等  待被调函数返回.

其中,只有ExecuteFunc参数是String,别的参数都是Code.        

注:触发信息,指的是GetTriggeringTrigger,GetTriggerUnit,等这些东西.
回复

使用道具 举报

发表于 2012-10-22 13:30:01 | 显示全部楼层
createtrigger
triggeraddcondition
call triggerevaluate
destroytrigger
就可以了
回复

使用道具 举报

发表于 2012-10-22 13:30:06 | 显示全部楼层
createtrigger
triggeraddcondition
call triggerevaluate
destroytrigger
就可以了
回复

使用道具 举报

发表于 2012-10-22 13:39:25 | 显示全部楼层
楼上你挖坟了

点评

明显是我楼上挖的啊 挖坟也不是我的问题吧...  详情 回复 发表于 2012-11-16 09:26
回复

使用道具 举报

发表于 2012-11-16 09:26:04 | 显示全部楼层
Asuna 发表于 2012-10-22 13:39
楼上你挖坟了

明显是我楼上挖的啊 挖坟也不是我的问题吧...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-2 17:57 , Processed in 0.113758 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表