[JASS] TriggerRemoveAction question

Status
Not open for further replies.
That is just an example on how to remove the triggeraction.

In reality, you will often destroy the triggeraction only after the function has finished.

Like this:

JASS:
function blah1 takes nothing returns nothing
    // blah blah blah
    // Function completed. Remove triggeraction

    call TriggerRemoveAction(tga_BKC, <your triggeraction handle>)
endfunction

function blah takes nothing returns nothing
    // blah blah blah
    call TriggerAddAction (trg_BKC, function Actions)
endfunction
 
Here you have example code:
JASS:
function aaa takes nothing returns nothing
    call BJDebugMsg("function aaa is running!")
endfunction

function InitTrig_bla takes nothing returns nothing
    local trigger t = CreateTrigger()
    local triggeraction ta = TriggerAddAction(t, function aaa)

    //make the trigger run
    call TriggerExecute(t)

    //remove the action
    call TriggerRemoveAction(ta)

    //run the trigger again
    call TriggerExecute(t)

    //destroy the trigger(prevent leaks)
    call DestroyTrigger(t)
    set t = null
    set ta = null
endfunction

this should make print function aaa running only once, if it does it twice, it is most likely blizzards fault for not making TriggerRemoveAction working
 
Status
Not open for further replies.
Back
Top