Unfortunately the thing is more problematic than I thought.
In Singleplayer mode the world isn't generated until you create a character - which is a problem because in the start() function there is tons of features relying on existence of various game objects. So moving most of the stuff from start() to the loop() and making sure the stuff runs only once sounded like a good idea, except one small detail - turns out loop() starts before world generation too...
What's worse 9 out of 10 times I get "character already logged in". I don't know if it goes away once all the null pointer errors get fixed. At this point I lost interest. Maybe I will return to the idea later, but if someone is interested, here is a pseudocode showing what needs to be done (that's the point 4.
)
In main.fos you have to move stuff from start() to loop() and rewrite loop() like that:
loop() {
if worldGenerated() {
if (firstTime) {
stuf_from_start();
}
stuff_from_loop();
}
}
How to check if the world is generated? I don't know if there is some nice way, but there is plenty of functions that run during the generation - map scripts, critter_inits etc. so it shouldn't be too hard to abuse them. Last but not least, thanks to Wipe for help.