ID:1487596
 
(See the best response by DarkCampainger.)
Code:
turf
icon = 'Environment.dmi'

Entered(atom/O)
var/area/AREA = src.loc
if(ismob(O))
var/mob/Player = O
if(Player.client)
var/SpawnChance = rand(0, 100)
if(SpawnChance < AREA.SpawnPercent)
var/Monster/ToSpawn = pick(AREA.MonsterList)

/* Instead of spawning the actual instance (depleting the list), spawn a copy of the monster in the list. */

var/Monster/Spawn = new ToSpawn.type
var/turf/SpawnLoc = pick(view(O))
var/area/SpawnArea = null
Spawn.Move(SpawnLoc)

if(Spawn.loc == null)
del Spawn
else
SpawnArea = SpawnLoc.loc

if(!isnull(SpawnArea) && SpawnArea.Safe) del Spawn //Error line

for(var/Monster/Sleeping in view(src, 20))
if(Sleeping.Idle || get_dist(src, Sleeping) > Sleeping.Attack_Range) continue
Sleeping.AI()

else ..()
else ..()


Problem description:

There's a lot here. Apparently I'm trying to access a variable on the mob /mob/var/Safe. HOWEVER. I see no place where that mixup may have occurred. Any ideas? The only thing I could imagine was an error in the Move() proc, but that's

mob
Move()
src.Moving = 1
..()
src.Moving = 0 // Pretty sure this line isn't reached but whatever.


Error:

runtime error: undefined variable /mob/var/Safe
proc name: Entered (/turf/Entered)
source file: Environment.dm,44
usr: Lugia319 (/mob)
src: Grass (12,17,1) (/turf/Grass)
call stack:
Grass (12,17,1) (/turf/Grass): Entered(Lugia319 (/mob), Grass (11,17,1) (/turf/Grass))
Lugia319 (/mob): Move(Grass (11,17,1) (/turf/Grass), 4, 12, 10)
Lugia319 (/mob): DetectStep(4)
Lugia319 (/client): East()
Will you please post the exact error? If it's an undefined variable it simply means that you never defined the variable "Safe" for an /area.

It's possible that you defined "Safe" variable for a subtype of /area
Best response
view() returns more than just turfs, so you could also be picking a mob or obj as your spawn location. Not sure how it's ending up with a mob in your SpawnArea var... maybe view() is returning an object in the mob's contents, so SpawnArea gets set to the mob itself?

Anyway, you should construct a separate list of just the turfs in view, and pick from that.
Aha, I had forgotten about that. Thanks DC.