• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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