• 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.

[JASS] TriggerRemoveAction question

Status
Not open for further replies.
Level 16
Joined
Dec 15, 2011
Messages
1,423
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
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
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.
Top