• 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 faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Checking regions sequentially

Status
Not open for further replies.
Level 14
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
933
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