ID:154838
 
I have a 25 by 25 array. I do a nested loop to roll a chance for a galaxy in each slot. This takes place under world.New() so that the galaxies are initialized at run time. They do not get displayed until a player logs in.

mob
Login()
..()
for(q=1, q<26, q++)
for(q1=1, q1<26, q1++)
if(galaxy_chance[q][q1] <= 6)
count1 += 1
x=q
y=q1
z=1
new/turf/galaxy1 (loc)
if (count1 == 1) new/area/galaxy1 (loc)
if (count1 == 2) new/area/galaxy2 (loc)
if (count1 == 3) new/area/galaxy3 (loc)
etc etc, and below that I have
area
galaxy1
Entered()
usr.loc = locate(1,1,2)
galaxy2
Entered()
usr.loc = locate(1,1,3)
galaxy3
Entered()
usr.loc = locate(1,1,4)
etc etc.

Is there any way to have the top code run on a loop or array in order to have the program create new unique instances of the galaxy# areas and new/area/galaxy# (loc) "portals" at run time rather than having to hard code them ahead of time?
var/path = "/area/galaxy[count1]"
new text2path(path)
In response to Zaoshi
I keep getting 160:error: text2path: undefined var
In response to Thaldor
Thaldor wrote:
I keep getting 160:error: text2path: undefined var

I can not code, but the error is simply telling you line 160 "text2path" is an undefined variable, and needs to be defined prior to use. Do not hold my word that will fix your problem, but thats what the error message is telling you.
var path = text2path("/area/galaxy[count1]")
new path(loc)


But from your code, I think you'd rather condense it like so:
area/galaxy
var teleport_z

New(Loc, Z)
..()
teleport_z = Z

Entered(mob/m)
..()
if(istype(m))
m.loc = locate(1, 1, teleport_z)

mob/Login()
..()
var count = 1
var a, b
for(a in 1 to 25) for(b in 1 to 25)
if(galaxy_chance[a][b] <= 6)
new /turf/galaxy(loc, ++count1)

// I don't know why you have "x=q; y=q1; z=1", but if that's really necessary:
loc = locate(a, b, 1) // a and b are both 25