Can I store actionFunc ?

Sooda

Diversity enchants
Reaction score
318
I know that Condition ( function RandomFunction) can be stored to boolexpr but can we store functions also ( TriggerAddAction(randomTrig, function RandomActionFunction) ? It () was first example what poped to my head. It isn' t connected with my older thread where I asked how to destroy trigger (I hope so.).
 

Tom Jones

N/A
Reaction score
437
Yea, it's easy. The function TriggerAddAction() returns the created triggeraction, so we can easily assign it to a triggeraction variable or store it with game cache systems:
Code:
function...
     local trigger trig ...
     local triggeraction tact ...

     call TriggerRegisterUnitEvet(trig, ...)
     set tact = TriggerAddAction(trig, ...)

     call SetHandleHandle(trig,"tact",tact)
     //You could also do choose not to set the variable, and do this instead:
     call SetHandleHandle(trig,"tact",TriggerAddAction(trig, ...))

     set trig = null
     set tact = null
endfunction
You can also assign the function that you add to the trigger to a variable. It's called code, and looks like this:
Code:
function...
     local trigger trig ...
     local triggeraction tact ...
[B]     local code actions = function SomeFunction[/B]

     call TriggerRegisterUnitEvet(trig,...)
     set tact = TriggerAddAction(trig,[B]actions)[/B]

     set trig = null
     set tact = null
     set actions = null
endfunction
You can't store codes with a game cache system though, because code isn't a handle.
 

Sooda

Diversity enchants
Reaction score
318
Dosn' t actions need to be destroyed ? Isn' there function like DestroyBoolExpr but instead DestroyactionFunc ? Or actions can be just nulled.

EDIT: I found TriggerRemoveAction and TriggerRemoveCondition, are they some how needed ?
 

Tom Jones

N/A
Reaction score
437
Yes, you should remove triggeractions and/or triggerconditions before destroying the trigger.
 

Sooda

Diversity enchants
Reaction score
318
I think when I create trigger and add actions after that I remove action what would happen ? I don' t want to destroy trigger I just want to know is action functions leaking ? Wierd question... I know.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top