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

Difference between Integer A, Integer B, custom integer?

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
what is the differance of these 3 actions?:

  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
  • For each (Integer B) from 1 to 10, do (Actions)
    • Loop - Actions
  • For each (Integer QB_Level) from 1 to 10, do (Actions)
    • Loop - Actions

edit: i get it now:) thanks for he explenation.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Custom variable is better since it's faster.

  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
->
JASS:
set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop

  • For each (Integer i) from 1 to 10, do (Actions)
    • Loop - Actions
->
JASS:
set udg_i = 1
    loop
        exitwhen udg_i > 10
        set udg_i = udg_i + 1
    endloop
One less variable setting.

And when you call the variable inside the loop:
  • Set ID = (Integer A)
->
JASS:
set udg_ID = GetForLoopIndexA()
So that calls a function that returns the value set to bj_forLoopAIndex.

  • Set ID = i
->
JASS:
set udg_ID = udg_i
No function call.
 
Integer A and B are blizzard global variables used in for functions!
It was faster for programmers to just pick 1 (usually A) variable already used with function and do what they need to do...
Still there was situations when they needed 2 functions so they added Integer B for just in case!
For function with custom variable is default one, basic thing :)
 
Status
Not open for further replies.
Top