• 🏆 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!

Cleaning up [Integer A] leaks

Status
Not open for further replies.
Level 10
Joined
Jun 10, 2007
Messages
557
So I have to use a Point variable array for a trigger I have and, obviously, I need to clean up the resulting leaks.

Do I have to do, for example;

  • Custom script: call RemoveLocation (udg_Location[1])
  • Custom script: call RemoveLocation (udg_Location[2])
  • Custom script: call RemoveLocation (udg_Location[3])
and so on, or does JASS have some way to refer to Integer A/B?
 
Level 7
Joined
Jul 18, 2009
Messages
272
"Integer A" in Jass is "GetForLoopIndexA()".
You could have found that out yourself by converting a trigger containing Integer A to custom script. :wink:
 
Level 2
Joined
Aug 28, 2009
Messages
20
There's a better way of doing it, just look at the function =p
JASS:
function GetForLoopIndexA takes nothing returns integer
    return bj_forLoopAIndex
endfunction
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
However: an Integer A-loop is not a very good loop, as it may bug with multiple loops and it uses BJ's.
It's best to use a normal loop (in fact: even in GUI you should use a normal loop instead of an Integer A/B-loop, this can be done with "For each integer Variable").

In JASS it becomes something like this:

JASS:
function loop takes nothing returns nothing
    local integer i = 0// Sets the integer you will use for the loop

    loop
        exitwhen i > 10 // defines when the loop will end, in this case it's a loop from 1 to 10.
        set i = i + 1 // increases i... otherwise the loop will never end
        
        call RemoveLocation[i] // you can set any other actions you wish to do here as well
    endloop

endfunction

It may look huge, but I strectched it out a lot so it looks better :p
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Actually you'll just get a thread crash if you use ap0calypse's version because he's leaving the integer uninitialized. Setting it to any value (0 preferably) will fix that though.
I was in a hurry (was working on another system), so I just forgot that

And what's wrong with that udg_i in the exitwhen?
Yeah, I'm used to working with GUI, where you always need to type "udg_", so I just mixed it up a bit.

And before you say it, I know that "call RemoveLocation" doesn't work because there is no variable given, but with a little bit of improvising, you know what to do there.

Everything should work fine now, though.
 
Status
Not open for further replies.
Top