ID:154968
 
can you create a loop so that if an area isn't occupied by a specific mob then it creates the mob on that area. this is my current code:

world
New()
while(locate(/area/gym1))
new /mob/chuck(locate(/area/gym1))
del locate(/area/gym1)

im creating a pokemon game and I wanted there to be 3 of the same person but it only makes 1
I'd say have a contents var of some sort (obviously not with that name) You also are thinking of a turf, and you don't want to delete the area when done.

<dm>
area // Areas
var // Area vars
MWithin = 0 // Mobs within

Gym // Gym Area

proc

Populate() // Populate proc
while(MWithin < 3) // While the mobs within counter is less than 3
var/list/L = list() // Define L to be an empty list
for(var/turf/T in src.contents) // This will loop through the area's contents (which should be turfs). In theory this should work but then again, Imma clueless dope.
L += T // Add the turfs to the list (references)
var/turf/NewTurf = pick(L) // Define NewTurf to be a turf reference chosen from L
new /mob/Monster (NewTurf) // Create a new mob at that turf
MWithin ++ // Add 1 to MWithin so there's no infinite loop

proc
for(var/area/Gym/G in world) // Loops through the Gym area
spawn(0) G.Populate // Spawn the populate for that gym