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

[Solved] A question about Triggers

Status
Not open for further replies.
Level 7
Joined
Dec 3, 2006
Messages
339
Destroy gets rid of a trigger for good. Turning it off is only well, turning it off. Map Init triggers only need be destroyed afterward.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
what's the difference between them?

This is "DestroyTrigger".
JASS:
native DestroyTrigger takes trigger whichTrigger returns nothing

This is "Trigger-Turn off Trigger" aka "DisableTrigger"
JASS:
native DisableTrigger takes trigger whichTrigger returns nothing

As you can see they are completly different native functions meaning there is very little chance of them behaving in a similar way.

DestroyTrigger's behaviour is implied by its name. It attampts to destroy the passed trigger handle, freeing the resources it used. In addition to this, it also will destroy all attached events. Apparently it does not destroy attached conditions and actions so those will have to be dealt with separatly with their appropiate deconstructors. Unfortunatly this function is not always sucessful when called and can instead result in a fatal error (game crash) in the case that a trigger is in a certain unsupported state during the deconstruction attempt.

DisableTrigger's behaviour is also implied by its name. It turns the passed trigger off preventing all bound events from executing the trigger. Disabling a trigger will obviously not free all tied up system resources.

Imagine a trigger being an airconditioning system keeping your house at a constant temperature. This is a good comparision as airconditioning also has events (changes in teperature), conditions (certain temperature settings) and actions (turn on heater / cooler).
DestroyTrigger is like ripping out the airconditioning control system. All teperature sensors are gone so is the control electronics but the teperature setting pannel (condition) still remains and the working elements (actions) also remain installed.
DisableTrigger is like turning off the airconditioning system. You can still turn it on again at any time and it will still exist in your house but it just will be off and do nothing.
 
This is "DestroyTrigger".
JASS:
native DestroyTrigger takes trigger whichTrigger returns nothing
What if you create the trigger again, will that be able to allow you to make new events?
if should I do it something like this?
JASS:
native CreateTrigger takes trigger whichTrigger returns nothing
also would doing this in a seperate trigger work?
JASS:
set whichTrigger = CreateTrigger()

Also Switch33 if you do it in jass you don't even need to create the trigger for map initialization.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
What if you create the trigger again, will that be able to allow you to make new events?
if should I do it something like this?
I do not understand what you are asking... You create triggers and events like always just you destroy them when they are no longer needed to free the system resources they used as they are no longer needed. Ofcourse you are meant to but the crash prone nature of DestroyTrigger means it is unsafe to use in certain situations.
 
I am just a GUI user that doesn't know to much about jass xD.
Anyway so if you create the trigger add actions then destroy the trigger the actions will be gone.
So if/when you recreate the trigger you would have to recreate the actions again right.
Just asking because this would beable to make using triggers with the event a unit comes within X.xx range of Unit would be more flexible.
JASS:
call TriggerRegisterUnitInRangeSimple(whichTrigger, 256, udg_Unit)

I am also asking if you can create the trigger again once destroyed once before.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Anyway so if you create the trigger add actions then destroy the trigger the actions will be gone.
No. You need to invoke the deconstructor on the action object specificly. People have reported the action deconstructors being faulty which is why conditions are used instead.

So if/when you recreate the trigger you would have to recreate the actions again right.
Yes, you will need to create another action binding object. There is no way to transfer action binding objects between triggers.

Just asking because this would beable to make using triggers with the event a unit comes within X.xx range of Unit.
The problem is destroying the trigger objects. The native to do so is not entirly stable and can cause game crashes.
 
Status
Not open for further replies.
Top