ID:841097
 
(See the best response by Neimo.)
Code:
        Createa()
set name = ".create2"
var/n = winget(usr, "window3.button6", "is-checked")
var/g = winget(usr, "window3.button7", "is-checked")
if(n == TRUE)
world.maxz+=1
var/p = world.maxz
usr.createdz=p
for(var/turf/A in world)
if(!istype(A, /turf/ground))
if(A.z == p)
new/turf/ground(A.loc)
// world << T
world << "A MADE"
winset(usr, null, "window3.is-visible=false")
winset(usr, null, "window1.is-visible=true")
return

if(g == TRUE)
world.maxz+=1
var/p = world.maxz
usr.createdz=p
for(var/turf/T in world)
if(!istype(T, /turf/ground2))
if(T.z == p)
new/turf/ground2(locate(T.x, T.y, T.z))
world << "B MADE"
winset(usr, null, "window3.is-visible=false")
winset(usr, null, "window1.is-visible=true")
return


Problem description:
Well, the code is supposed to get where either one of two radios are checked, then it creates a new maxz and is supposed to create a turf of specific type on each normal turf in the new z level.
The world turf var = /turf. The game lags and doesn't create anything, even if I set the maxx/maxy to 10 or a lower value.
Any idea?

Best response
n and g will always return a true value, winget() is returning "false" or "true". Your second if() check could be used under one statement, as well.

mob/proc/addmaxz()
var/a = winget(src, "window3.button6", "is-checked")
var/b = winget(src, "window3.button7", "is-checked")

if(a == "false" && b == "false")
return

world.maxz ++

for(var/turf/t in world)
if(a == "true" && !istype(t, /turf/ground))
do whatever
else if(b == "true" && !istype(t, /turf/ground2))
do whatever

if(a == "true")
winset(src, "window3.button6", "is-checked=false")
else
winset(src, "window3.button7", "is-checked=false")
In response to Neimo
Oh, thank you!