ID:154336
 
I don't know if this is silly or not, I just thought about the idea of saving objects from the game and restoring them for later use. I'd like to know if anyone has any reasons why something like this wouldn't work.

Okay, I've got a world full of objects and, being what I like it's in the format of a text MUD. So, when I start up the world after all the initial things are completed, it runs a little loading program that opens a savefile and takes any objects from the file and scatters them onto their saved x,y,z locations. Later, when the game is closed down, it takes all objects from the game, saves their x,y,z to new variables, and stuffs them into the savefile.

The only problems I can think of with this would be having items that start out on the map, and you would then end up with doubles every time you loaded the objects. The best way around this would probably be to have an obj/saved subdirectory where only the things you want saved are included, such as little items or vehicles, but not furniture.

Anyone see any problems with this idea?
I'd handle your problem sort of like this..

Every five or ten minutes, it saves all objects in the world.. just sort of crash protection.

On world shutdown it also saves. On world startup it loads and places them all.. then it puts all the other objects on, checking for duplocates of things that shouldn't have duplicates. This is just a general outline I'm thinking up as I write, so I may be wrong..

Oh, just don't place any object on the map, but place object spawns on world startup in a proc somewhere..

Hope this helps..

--Tarmas.
In response to Tarmas
I don't know how much map saving experience you have, but this seems evident to me: saving the map every 5 to ten minutes seems quite impractical, primarily because map saving generally induces monsterous amounts of lag for short periods of time. The fastest map saving program I have ever built can save a 500 x 500 map to a single save file in ten seconds of intense lag. Do that once every ten minutes and your players get a bit pissed. Do it with a world shut down like so, and you have fewer problems:
var/firstmob
mob/Login()
if(firstmob == null)
firstmob = src
src.verbs += /mob/proc/shutdown
..()
mob/proc/shutdown()
world << "<font size='4'>World Shutting Down!</font>
for(var/mob/M in world)
if(M.client && M != firstmob)
del(M)
src.loc = null
SaveWorld() // your map saving proc
del(world)
mob/Logout()
..()
if(firstmob == src)
shutdown()
In response to Lord of Water
Lord of Water wrote:
I don't know how much map saving experience you have, but this seems evident to me: saving the map every 5 to ten minutes seems quite impractical, primarily because map saving generally induces monsterous amounts of lag for short periods of time.

The trick is to only save things that have changed. No need to keep saving the world if 99% of things haven't changed.

My approach has been to store things in a manner that supports random access (you can get at any saved object at any time without having to read in other objects).

Either way if you want to get into saving, you probably want to look at this write up about savefiles:

http://www.deadron.com/Games/ByondBasicSavefiles.html
In response to Deadron
Oh yes, i do want to think you for writing that guide/tutorial on save files. When i came back to byond from my leave, that was the first thing i read. And now i have no trouble doing save files anymore. I had a few troubles yesterday, but i managed to sort it out.

FIREking