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

Need help with "For Each Integer A"

Status
Not open for further replies.
Level 8
Joined
Jul 17, 2004
Messages
283
Does this have the same effect as...

  • Unit - Create 1 Knight for Neutral Passive at (Center of Region <gen>) facing 180.00 degrees
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Hero[(Integer A)] Equal to No unit
        • Then - Actions
          • Set Hero[(Integer A)] = (Last created unit)
        • Else - Actions
This?

  • Unit - Create 1 Knight for Neutral Passive at (Center of Region <gen>) facing 180.00 degrees
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Hero[1] Equal to No unit
    • Then - Actions
      • Set Hero[1] = (Last created unit)
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Hero[2] Equal to No unit
        • Then - Actions
          • Set Hero[2] = (Last created unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero[3] Equal to No unit
            • Then - Actions
              • Set Hero[3] = (Last created unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Hero[4] Equal to No unit
                • Then - Actions
                  • Set Hero[4] = (Last created unit)
                • Else - Actions
What I'm trying to do is. I want to save Hero into a variable. And I want it to check 1-4 in order, and then stop once it finds a variable that has 'No Unit' set. I'm worried with Each Integer A it will assign Hero 1-4 for all of them.
 
The unit created was of his example so I was just using it so he knows where to start, I wasnt going full out on it but yes it does

If you make something that leaks or is not efficient you should always say so. It makes it so that newer people or people looking at this don't get confused thinking that that is a leak free efficient trigger.
 
Status
Not open for further replies.
Top