ID:1688714
 
(See the best response by Kaiochao.)
Code:
world
proc
O()
var/SS = rand(1,2)
if(SS == 1)
for(var/area/Climax/C in world)
var/I
I++
if(C.ClimexID == 1)
C.Climax = "Snow"
new /turf/Snow(locate(C.x,C.y,C.z))
world << "[C.x] [C.y] [C.z]"
var/S = rand(1,2)
if(S == 1)
new /obj/SnowTree(locate(C.x,C.y,C.z))
..()
else
..()
if(SS == 2)
for(var/area/Climax/C in world)
if(C.ClimexID == 1)
C.Climax = "Desert"
new /turf/Desert(locate(C.x,C.y,C.z))
var/S = rand(1,2)
if(S == 1)
new /obj/Cactus(locate(C.x,C.y,C.z))
..()
else
..()


Problem description:

I've tried everything to make this work but it only spawns it at 1,1,1 in the world i dont know why.
/area objects only exist as one instance per type. Their coordinates correspond to the bottom-left-most tile they contain.

If you want to iterate over every turf in an area, you should loop through every turf in the area:
for([every turf] in [the area])
(DM isn't nearly as complicated as many make it seem)

Also, you clearly don't understand what ..() is, so you should probably do some reading on that. Mainly, you should not be calling ..() even once in this entire snippet.
I get it now!

world
proc
O()
var/SS = rand(1,2)
if(SS == 1)
for(var/turf/C in /area/Climax)
var/I
I++
if(C.ClimexID == 1)
C.Climax = "Snow"
new /turf/Snow(locate(C.x,C.y,C.z))
world << "[C.x] [C.y] [C.z]"
var/S = rand(1,2)
if(S == 1)
new /obj/SnowTree(locate(C.x,C.y,C.z))
else
..()
world << "[I]"
if(SS == 2)
for(var/area/Climax/C in world)
if(C.ClimexID == 1)
C.Climax = "Desert"
new /turf/Desert(locate(C.x,C.y,C.z))
var/S = rand(1,2)
if(S == 1)
new /obj/Cactus(locate(C.x,C.y,C.z))
else
..()


This is my new code now but i cant check the climax ID anymore because it checks the Turf instead of the Area anyway i can make it check the area of the turf?
In response to R0nny
Best response
R0nny wrote:
I get it now!
I disagree.

There is only one /area/Climax in existence, and it contains every turf it covers, just like how a player would contain every item inside it. How would you loop through every item inside a player?
// in this context, "player" is a variable referring to the player we're working with
// and /obj/item is the type of object we're iterating over, inside the player
for(var/obj/item/thing in player)
(also I think you may mean "climate", not "climax")

I'm assuming you have subtypes for every type of climate in your world. If not, you should fix that, since you didn't understand before that one area type = one instance only. So, you would still loop over every climate in the world, and then loop through every turf inside that climate.
// I'm guessing this is what you're trying to do. 

// You're placing certain /area/climates over regions of the map
// to say what kind of stuff should be generated there.
area/climate

// Every climate has a default turf that fills it.
var default_turf

// When a climate generates, it operates on every turf inside it.
proc/Generate()
for(var/turf/t in src)
GenerateTurf(t)

// This is what happens to every tile in this climate.
proc/GenerateTurf(turf/T)
new default_turf (T)

// snowy climates are filled with snow turfs
snow
default_turf = /turf/Snow

// every tile has a 50% chance of having a snow tree
GenerateTurf(turf/T)
// do the inherited action (create a default_turf at T)
..()

// 50% chance of having a snow tree
if(prob(50))
new /obj/SnowTree (T)

desert
default_turf = /turf/Desert
GenerateTurf(turf/T)
..()
if(prob(50))
new /obj/Cactus (T)

blah
default_turf = /turf/Blah

world
proc/GenerateClimates()
// loop through every type of climate and generate it
// (this is actually a very horrible way of generating a world, all at once)
for(var/area/climate/c)
c.Generate()
I don't think you get my code as much, i want the climates to be random. But everything else is totally right.
In response to R0nny
I see, your code shows that your world is either completely snow or completely desert.
Yeah, but what i ment it's completely snow or completely desert for only that ClimexID.