• 🏆 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!

[Trigger] simple loop within a loop

Status
Not open for further replies.
Level 3
Joined
Jul 26, 2013
Messages
41
I want to place 20 random patches of trees on my map but this trigger won't work (it runs just once and places 1 patch of trees)

  • Melee Initialization
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Set trees_clump = (Random point in (Playable map area))
          • For each (Integer A) from 1 to 20, do (Actions)
            • Loop - Actions
              • Destructible - Create a Snowy Tree Wall at (Random point in (Region centered at trees_clump with size (800.00, 800.00))) facing (Random angle) with scale 1.00 and variation 0
 
When the inner loop ends, the "Integer A" has the value "20" already, so the first loop will also directly end after the first run.

Use IntegerB for the second loop - or even better is to use "Custom Integer Loop" and take usage of your own integer variables.

Edit: You leak memory. In case you want to inform about it http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/.
 
Status
Not open for further replies.
Top