• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Trigger Action....

Status
Not open for further replies.
Level 5
Joined
Jun 10, 2010
Messages
145
Hello, my question is realy simple (but I can't solve it:goblin_boom:).

Well here it comes:
Can someone explain me for what is used the action "For each (integer A) from 1 to 10, do action" ???

Thanks.
 
Firstly, integer A is a integer variable that created by blizzard.If something needs to be done more than a few times, use that action.Following example will be executed 4 times.

  • For each integer A 1 to 4
    • Unit - Cause UnitA to damage UnitB
    • Wait 1.00 seconds
means, when integer A equal to 1, do actions under the loop, increase integer A, when integer A equal to 2, do actions..... until 5
  • Unit - Cause UnitA to damage UnitB
  • Wait 1.00 seconds
  • Unit - Cause UnitA to damage UnitB
  • Wait 1.00 seconds
  • Unit - Cause UnitA to damage UnitB
  • Wait 1.00 seconds
  • Unit - Cause UnitA to damage UnitB
  • Wait 1.00 seconds
 
Its used as a crap for loop cause GUI does not grant you access to the "loop", "exitwhen [boolean]" and endloop constructs.

What this means is that it enables you to use repetation to carry out tasks, and that repetation itself can be variable. This lets you vary how many times a piece of code gets executed very easilly unlike if you "unwind" the code whereby you can not control its itteration.
 
http://en.wikipedia.org/wiki/For_loop

Wikipedia ;)

The "Trigger Editor" is really what you consider a "Graphical User Interface" for a programming language called JASS, which was developed by Blizzard for users to create custom games. Therefore, any time you want to know about what a "trigger" is really doing, you should right-click on it and request "Convert to custom text". Just ignore the warning it prompts with ("cannot be undone") as it is a lie - you can undo it with a simple "Ctrl + Z" action.

You will see:

  • For each (integer A) from 1 to 10, do actions
Converted to:

JASS:
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
    // Actions
    set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop

Which could be viewed from another programming language differently, without so much text and, to be honest, a lot faster performance:

Code:
for (int i=1; i<=10; i++) {
    // Actions
}
 
Well I know how convert triggers to custom text, but still, your post helped too.:ogre_haosis:

I'm trying to learn Jass language by the Hive's tutorials. But its realy hard, one single mistake can screw up an entire trigger. Hehe.
 
Status
Not open for further replies.
Back
Top