• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Calling Actions inside Condition.

Status
Not open for further replies.
Level 21
Joined
May 16, 2012
Messages
644
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