Trigger handle index issues

saw792

Is known to say things. That is all.
Reaction score
280
I'm having some issues with triggers.

In a test map that only creates one trigger I use H2I to get it's index. However, when attempting to check that that is the only trigger that has been created (by converting the index + 1 to a trigger with I2H) it does not return null, implying that a legitimate trigger exists at index + 1.

I also tested at index + 100, index + 999999, index - 1, index - 99999... and nothing returns null.

How can I check if the trigger actually exists (i.e. to find out how many triggers actually exist at that time)?
 

Strilanc

Veteran Scripter
Reaction score
42
Well of course if you add 1 you're not going to get null. A handle is just an integer being treated in a special way, so the only handle index that will be 'null' is 0.

If you want to know if a given handle index is a trigger, cast it to a trigger and try to add an action. If TriggerAddAction returns null, it's not a trigger. Remember to remove the action if it actually is a trigger, though.

I know it works because in my submission for the wc3c spell olympics contest, I had a joke 'dark' spell called meta. Meta picks a random handle index, and tries to destroy it by figuring out its type and calling the appropriate remove/destroy function.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top