• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Integer A / Integer B

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

First of all I never use this action triggers because I dont know the function

  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
  • For each (Integer B) from 1 to 10, do (Actions)
    • Loop - Actions
Can someone explain me (understandable) what they do? what is Integer A/B? and what is from (1) to (10)?

Thanks =)
 
Level 6
Joined
Oct 31, 2008
Messages
229
Ok lets say you got integer A
This means that you put a starting value and an ending value and the integer A, takes all values between them.
e.g.
For each (Integer A) from 1 to 10, do (Actions)
Loop
Comment - Here you put the code and is much usefull when you have to handle arrays.
e.g. set variable ARRAY[Integer A]= value

it will start as 1, then 2 3 4 5 6 7 8 9 10
 
Well to telly you this way:

Let's say you would like to create 10 footmans.
And you would copy and paste "create one footman for...." 10 times.

With loops you just make one action ad it will repeat X times.

Like:

(without loop)

  • No Loop
    • Events
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
(with loop)
  • Loop
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
But there is more that just creating footmans, you can make much more by using it.
 
There is no difference. If you feel to use A or B or C or any other :p Actually you can use any integer for it.

You can make it look like:

  • For each (Integer A) from 1 to (Number of units in (Units in (Playable map area))), do (Actions)
    • Loop - Actions
Really you can do so much with it.
(2 pages of explanation and examples wouldn't be enough) I suggest you take a look after spells in spell section, I'm pretty sure every second spell is using loops.
 
Level 8
Joined
Aug 13, 2009
Messages
466
Integer A and Integer B are two global variables that Blizzard created to help GUI triggerers make simple loops. The A and B are there if you would want to use two variables in the same loop or create a loop inside another loop for whatever reason.

I'm not sure whether Integer A or B would get reset to its default value if you use multiple loops after each other in the same trigger, I would not know.
 
Level 14
Joined
Jun 13, 2007
Messages
1,432
  • For each (Integer A) from 1 to 11, do (Actions)
    • Loop - Actions
      • Multiboard - Set the width for SkillTreeMultiboard[(Integer A)] item in column 1, row 1 to 20.00% of the total screen width
      • Multiboard - Change the number of rows for SkillTreeMultiboard[(Integer A)] to 20
      • For each (Integer B) from 1 to 20, do (Actions)
        • Loop - Actions
          • Multiboard - Set the display style for SkillTreeMultiboard[(Integer A)] item in column 1, row (Integer B) to Show text and Hide icons
This is how I used it for 11 diffrent multiboards that were gonna look the same.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
General loop-info

Loops are probably the most useful actions for easily creating efficient triggers, since it goes through the same actions multiple times.
If you combine that by using the variable in the looped actions, you can create special effects (such as a circle around the caster), multiboards (syltman's example), player alliances, systems, anything you want.
The calculator-system I made once, for example, uses a lot of loops.

I cannot imagine a good custom map without loops...

But because Integer A is a BJ in jass (it calls another function), it might not function properly when multiple integer A's are running at the same time (pretty rare, unless you use waits in the loop, then it's pretty much screwed).
The best thing is to create an integer with an array and loop that integer, instead of the Integer A/B...
I'm not sure whether Integer A or B would get reset to its default value if you use multiple loops after each other in the same trigger, I would not know.
Yes, they are:
Because you say "For each integer A from X to Y", integer A is set to X before the loop. (the same for Integer B, of course).
So if you use them multiple times in the same trigger, they'll get reset.

Though, if you use multiple loops (like syltman), you have to use 2 different integers, that's why Integer B exists, otherwise the second loop would overwrite the first.


Special Effect (circle around caster)
  • For each (Integer i[1]) from 1 to 10, do (Actions)
    • Loop - Actions
      • Set loc[1] = (Position of (Triggering unit))
      • Set loc[2] = (loc[1] offset by 300.00 towards ((Real(i[1])) x 36.00) degrees)
      • Special Effect - Create a special effect at loc[2] using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
      • Custom script: call RemoveLocation(udg_loc[1])
      • Custom script: call RemoveLocation(udg_loc[2])
Aliance (players 1-6 are allied with this)
  • For each (Integer i[1]) from 1 to 6, do (Actions)
    • Loop - Actions
      • For each (Integer i[2]) from 1 to 6, do (Actions)
        • Loop - Actions
          • Player - Make (Player(i[1])) treat (Player(i[2])) as an Ally with shared vision
Custom Progress Bar (Multiboard)
  • For each (Integer A) from 2 to 9, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of Paladin 0000 <gen>) Greater than or equal to (>=) ((10.00 x (Real((Integer A)))) - 5.00)
        • Then - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of Paladin 0000 <gen>) Greater than or equal to (>=) (10.00 x (Real((Integer A))))
            • Then - Actions
              • Multiboard - Set the icon for Multiboard[1] item in column ((Integer A) + 1), row 1 to Icon[((Integer A) + 2)]
            • Else - Actions
              • Multiboard - Set the icon for Multiboard[1] item in column ((Integer A) + 1), row 1 to Icon[((Integer A) + 10)]
        • Else - Actions
          • Multiboard - Set the icon for Multiboard[1] item in column ((Integer A) + 1), row 1 to Icon[1]
 
Status
Not open for further replies.
Top