ID:169511
 
I have a 'setup()' proc which I would like all areas to run when they are created. This proc generates info which will be needed when a player enters the area.

Here is a usless example:
area
var
RandNum
proc
setup()
RandNum = rand(1,16)
New()
setup()
.=..()
Entered(var/atom/movable/M)
M << RandNum


This example works for areas created at runtime, but not for areas loaded from the .dmp file. My question, is how can I force my areas to call setup() as soon as they exist?

I would do something like this [see code below] but that always causes problems if you don't add a 'spawn(20).' Normally, this would be acceptable, but after 20 ticks a lot of mobs could already have been placed on the map without getting the RandNum displayed to them.
world
New()
..()
spawn(20)
for(var/area/A in contents)
A.setup()


So, is there a way to cause areas (or anything, for that matter) to execute a command as soon as they exist?
Perhaps using a smaller number for spawn?
world/New()
..()
spawn(2)
for(var/area/A in world)
A.setup()