• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] I dont understand this trigger action!

Status
Not open for further replies.
That action will run everything inside it 10 times, this is called a loop.

  • For each(Integer A) from 1 to 10, do (Actions)
You can modify this loop by changing number 1 and 10. At this case number 1 is the start number for the loop and number 10 is the end number. So this loop will loop through itself 10 times.

If you change it to:
  • For each(Integer A) from 1 to 100, do (Actions)
it will loop 100 times.

And this loop:
  • For each(Integer A) from 6 to 20, do (Actions)
will loop 15 times

Example:

This trigger below here will print out the text "Hello World!" five times at the screen, but with a loop you can do it A LOT simpler!
  • Loop Test
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Hello World!
      • Game - Display to (All players) the text: Hello World!
      • Game - Display to (All players) the text: Hello World!
      • Game - Display to (All players) the text: Hello World!
      • Game - Display to (All players) the text: Hello World!
The same trigger above but with a loop:

  • Loop Test
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: Hello World!
Do you get it? You can play around a lot with loops, this is just basics.
 
tjordell, what you said was rather pointless. Firstly WC3 can not handle that left number cause it is greater than an signed integer of size 32 bits. Secondly a loop with fewer itterations than that you mentioned would easilly hit the op limit and thus cause a "thread crash" which basically means code will stop executing once the limit is reached.

exitwhen true
Can be used as a hard coded break out of a loop. This is not that often used cause you can just place the conditional code after the loop but in some cases could be useful.

exitwhen u = null
Is used for an unefficent enum. Basically where you loop through a group of units by getting the first unit and removing that from the group repetitivly. Works with forces as well but generally its better to enum through the group/force (faster).

You can even have more complex conditions and still be valid but in the end it is entrily up to what you need.
 
Status
Not open for further replies.
Back
Top