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

[Trigger] Searching an array

Status
Not open for further replies.
Level 7
Joined
Jul 29, 2009
Messages
276
when the trigger fires the game crashes:
  • Using Trebuchet
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 8000, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to MachineUser[(Integer A)]
            • Then - Actions
              • Game - Display to (All players) the text: triggerd used
              • If ((Ability being cast) Equal to Inventory (Hero)) then do (Do nothing) else do (Unit - Order (Triggering unit) to Stop)
            • Else - Actions
              • Do nothing
basicly i want to search the array and find if the triggering unit is inside of it. the array may contain a lot of other units and null units.

how do i do it?
thx.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Ordering the unit to stop will cause the trigger to fire again, ad infinitum.

Also, add this line at the bottom of your THEN in the if statement:

Custom script: exitwhen true

That will cause the loop to immediately exit rather than needlessly going on.

--

However, you should look in to hashtables in 1.24.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Am I missing something here? I thought a "new" function process was created each time the trigger is called, thus making exitwhen true useless. o_O

Say it always finds the number at index 1000.
It runs 1000 times, calls the function, runs 1000 times, calls the function runs...

However if it was fixed (with some conditions), it would run 1000 times, do whatever it's supposed to do, and then run the next 7000 iterations for no reason.

You should keep a count of how many indices your array is using, so you don't have to do a loop of 8000 -_-

Thus why Poot told him to use "exitwhen true".
 
Status
Not open for further replies.
Top