• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Calling Actions inside Condition.

Status
Not open for further replies.
Level 20
Joined
May 16, 2012
Messages
635
Hello Hivers, recently i saw in a post that its better to do:

JASS:
scope Test initializer Init

private function Actions takes nothing returns nothing
    Do Something...
endfunction

private function Conditions takes nothing returns boolean
    if Some_Condition_Check then
        call Actions()
    endif
    return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
    set gg_trg_Test = CreateTrigger()
    call TriggerRegisterVariableEvent( gg_trg_Test, "udg_AnyVariable", EQUAL, 1.00 )
    call TriggerAddCondition(gg_trg_Test, Condition( function Conditions ))
endfunction

endscope

Then

JASS:
scope Test initializer Init

private function Conditions takes nothing returns boolean
    return Some_Condition_Check == true
endfunction

private function Actions takes nothing returns nothing
    Do Something...
endfunction
//===========================================================================
private function Init takes nothing returns nothing
    set gg_trg_Test = CreateTrigger()
    call TriggerRegisterVariableEvent( gg_trg_Test, "udg_AnyVariable", EQUAL, 1.00 )
    call TriggerAddCondition(gg_trg_Test, Condition( function Conditions ))
    call TriggerAddAction( gg_trg_Test, function Actions )
endfunction

endscope

because trigger actions create threads and trigger conditions do not. I dont quite understand the concept. What are the pros and cons of each method? Will it impact performance? Will it break MUIness?
 
Status
Not open for further replies.
Top