• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[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