Code:
var/global/datum/controller/generator/map_generator/mapgenerator //Set in world.New()
datum/controller/generator/map_generator
var/list/turflist = list() // Pre-generate this list when initializing for quicker setup.
var/list/completedtiles = list()
var/list/minerals = new/list(
/turf/walls/mineral/copper,
/turf/walls/mineral/iron
)
datum/controller/generator/map_generator/proc/SpawnMinerals()
world.log << "HAI THERE"
for(var/turf/walls/mineral/M in minerals)
M = new(locate(1, 1, 1))
if(M)
var/rarity = M.rarity
var/turf/spawnloc = pick(turflist)
while(5000)
world.log << "While Loop"
if(prob(rarity))
M = new(spawnloc)
Problem description:
It doesn't work. I can see the 'HAI THERE' message appear, but it never gets to the 'While Loop' part.
The line after the for loop was added because It was incapable of finding M.rarity (null), even when I gave it the mineral type directly.
I'm at a loss here, and could use some help.
Means something.
while(5000) is pretty much saying
while nothing is 5000 do something.
The only instance where something like this works would be
while(1) which equates to while(true), which will be an infinite loop.
As for why you need to use new() inside of the for(), you can't access the variables of something that doesn't exist, a type-path is just that, a type-path, it's not an object.
You're pretty much trying to access variables that don't actually exist until you create a new() object of that type.
You should be doing