HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Dynamic Triggers

09-06-2009, 01:32 PM#1
Silvenon
Well, I have a question about dynamic triggers. When am I allowed to create a single boolexpr for the condition which I would reuse and when do I have to create a boolexpr each time I create the trigger? Example:

Collapse JASS:
scope Spell

    function TrigCond takes nothing returns boolean
        // ...
    endfunction

    function Func takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegister...
        
        call TriggerAddCondition(t, Condition(function TrigCond))
        
        // ...
        
        set t = null
    endfunction

endscope

Collapse JASS:
scope Spell initializer Init
    
    globals
        boolexpr E = null
    endglobals

    function TrigCond takes nothing returns boolean
        // ...
    endfunction

    function Func takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegister...
        
        call TriggerAddCondition(t, E)
        
        // ...
        
        set t = null
    endfunction
    
    function Init takes nothing returns nothing
        set E = Condition(function TrigCond)
    endfunction

endscope

I hope you understand my question.
09-06-2009, 01:40 PM#2
Anitarf
Why would you need dynamic triggers?

Anyway, both of your examples should yield the same result.
09-06-2009, 06:23 PM#3
Silvenon
Well... arghh! Yeah, now I realized that I can have a single trigger for that, bah. Thanks.

They should? So whatever is in the "conditions" function, it doesn't matter, right? Cool, that's what I wanted to know.