ID:1995209
 
(See the best response by Kaiochao.)
Code: None.


Problem description:
Simply put, I am wondering how I would activate a procedure on the start of the world (for example, auto saves).
Best response
world.New() is called automatically, around when the world starts up.
world
New()
// code goes here
To elaborate, world.New() is called AFTER the map has already initialized, which may not be what you're after, you can however force a proc to run before world initialization by defining a datum as a variable something like

pre_init
New()
world<<"This happens before map initialzation!"

var/pre_init/pre_init = new()


However order of operations is important with this, it must be placed before any other code is written in your game (As in, literally line 1 of the first .dm included in your file) to avoid running into any strange issues.
In response to Kaiochao
Thank you, perfect for what I needed!
I have question to auto saves proc...
Better is call it for player when he is loggining
mob
Login()
src.Autosave()

or call it for world?
world/New() Autosave()

proc/Autosave()
for(var/mob/players/M in world)
...........


I think 1st method is faster, but i'm not sure.
Those two snippets do vastly different things. One of them saves when the player logs in, the other saves when the world starts up.

If you're asking "Should I have a bunch of loops for autosaving on each client, or a single loop which calls something on each client?" the answer is ALWAYS the latter. It's basically a rudementary update loop, and it'll always run significantly faster than having a bunch of loops flooding your threads.
mhm in all you're right, thanks for quick answer.