ID:174651
 
When the CheckArenas() proc is called I want to check if a global var has a value. If it does I want to check if another Global var has a value and on for about 5 times. Then the same thing with another type of Global var. The way I'm doing it is long and not very efficient. Does anybody know of a better way to make this shorter?

mob/proc/CheckArenas(mob/M,mob/usr,turf/T)
for(T in usr.loc)
if(T.type == "Grass")
if(grassarena1)
if(grassarena2)
if(grassarena3)
if(grassarena4)
if(grassarena5)

else
usr.loc = locate(0,0,0)//Placewehre arena one is
M.loc = locate(0,0,0)
grassarena5 = 1
usr.arena = "grassarena5"
else
usr.loc = locate(0,0,0)//Placewehre arena one is
M.loc = locate(0,0,0)
grassarena4 = 1
usr.arena = "grassarena4"
else
usr.loc = locate(0,0,0)//Placewehre arena one is
M.loc = locate(0,0,0)
grassarena3 = 1
usr.arena = "grassarena3"
else
usr.loc = locate(0,0,0)//Placewehre arena one is
M.loc = locate(0,0,0)
grassarena2 = 1
usr.arena = "grassarena2"
else
usr.loc = locate(0,0,0)//Placewehre arena one is
M.loc = locate(0,0,0)
grassarena1 = 1
usr.arena = "grassarena1"
Use a single variable like this:
switch(Arena)
if(0)
//blah blah blah
else if(1)
//more blah blah
etc etc etc

Hope you understand what i'm trying to say
In response to FranquiBoy
No not really. Even if, I don't see how I could implement it into the code I already have. Then I have many "types" of arenas such as Grassland, Dirt, Cave ect. I have 5 of each type of arena.
In response to SSChicken
Do variables grass, dirt, etc instead of just arena
You dont have to change it, just a suggestion.