- Joined
- Jun 26, 2020
- Messages
- 1,884
If I create a trigger I can normally do:
But we can also just do
Or
But if the actions need local variables, to save steps we can use the first way:
Or is more efficient this?:
What do you think?
vJASS:
function Actions takes nothing returns nothing
//bla bla
endfunction
function Conditions takes nothing returns boolean
return bool
endfunction
function Init takes nothing returns nothing
set t=CreateTrigger
call TriggerRegisterEvent(t,<Whatever>)
call TriggerAddCondition(t,Condition(function Conditions))
call TriggerAddAction(t,function Actions)
endfunction
vJASS:
function Actions takes nothing returns nothing
if bool then
//bla bla
endif
endfunction
function Init takes nothing returns nothing
set t=CreateTrigger
call TriggerRegisterEvent(t,<Whatever>)
call TriggerAddAction(t,function Actions)
endfunction
vJASS:
function Conditions takes nothing returns nothing
if bool then
//bla bla
endif
endfunction
function Init takes nothing returns nothing
set t=CreateTrigger
call TriggerRegisterEvent(t,<Whatever>)
call TriggerAddCondition(t,Condition(function Conditions)) //Yes the condition can accept a function that returns nothing
endfunction
vJASS:
function Actions takes nothing returns nothing
local type x
//bla bla
endfunction
function Conditions takes nothing returns boolean
return bool
endfunction
function Init takes nothing returns nothing
set t=CreateTrigger
call TriggerRegisterEvent(t,<Whatever>)
call TriggerAddCondition(t,Condition(function Conditions))
call TriggerAddAction(t,function Actions)
endfunction
vJASS:
function Actions takes nothing returns nothing
local type x
//bla bla
endfunction
function Conditions takes nothing returns nothing
if bool then
call Actions()
endif
endfunction
function Init takes nothing returns nothing
set t=CreateTrigger
call TriggerRegisterEvent(t,<Whatever>)
call TriggerAddAction(t,function Conditions)
endfunction