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

Checking regions sequentially

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
I have some rects on my map, and I need to use a few of them to check if a unit will spawn there. There are 21 to check. I need to check which rect was entered in order to find out if the unit will be respawning in it.

Instead of doing a ton of if thens, I would like to do a loop instead. I want to loop thrugh the rects.

My first idea was to rename the rects to start with a number, then loop an integer + 1 every time and check by converting it to a string. But I don't know how to convert the name of the rect.

Is there some easy way to loop through rects?
 
Level 9
Joined
Nov 4, 2007
Messages
931
Except start at 0 because that's how arrays work.

Also, a string would not work because WC3 does not use strings to look at a variables name.

STOP!! BLASPHEMA!!
Well I was just using an example, as poor as it was, but yes its never too late to begin good practice, always start your arrays from 0, never 1. And I don't think that he meant using S2I like ArrayVariable[S2I] I think he meant GetNameOfRect(whatever its called) then if his Rect was named Square01 then he could S2I the last few characters of a string and then check them either with an integer comparison or simply placing those in the array, don't know if its doable though. E.g. GetRectNameorString(Square01),if (Convert last 2 characters of string "Square01" to Integer) == 1 then do actions:
 
Status
Not open for further replies.
Top