ID:179049
 
How would I go about saving a map? I haven't done much with saving yet... could someone give me a quick example?

[edit]
I should make this more clear... in my game, people can build things. But, whenever the server restarts or crashes, it all goes poof. I'd like to have a way in which I can save the world when the server crashes.
I have the same type of game...
I think you could either:
A) Save the whole thing
B) Save everything but a tile, say grass.

My beta code for this is:
proc/worldsave()
var/savefile/sworld = new("world/world.sav")
sworld["worldsave"] << world.contents

proc/worldload()
var/savefile/lworld = new("world/world.save")
lworld["worldsave"] >> world.contents

Too bad it has an error. ;(

P.S. WARNING: The above save code is bad. It will crash Dream Seaker trying to save the world.... (Must... think up... better... way!)
In response to Nova2000
I tested this and it works awesome.


proc/Saveworld()
var/turf/O
var/savefile/F=new("world.sav")
for(O in world.contents)
F<<O

proc/loadworld()
var/turf/O
var/savefile/F=new("world.sav")
for(O in world.contents)
F>>O

obj/stuff
icon='s.dmi'
Click()
usr.thing=/obj/stuff

mob/var
thing

mob
icon='m.dmi'

turf
icon='t.dmi'
Click()
overlays+=usr.thing

mob/Stat()
statpanel("thing")
stat(new/obj/stuff)

world/New()
loadworld()
..()
world/Del()
Saveworld()
..()
In response to Super16
i came across theses posts and wanted to see if the map saves would work for me since i'm in the same postion. They didn't work. could someone tell me if i need a verb before the code that was not posted? it would really help me out
In response to Alienman22774
There's a library on map saving but it's far too advanced for you which is why it's "invite only".
In response to Nova2000
Okay... I've almost got it.. just how do I restore multiple obj from a savefile?

proc/Saveworld()
var/obj/O
var/savefile/worldsave=new("world.sav")
for(O in world.contents)
worldsave<<O

proc/loadworld()
var/obj/O
var/savefile/worldload=new("world.sav")
for(O in world.contents)
del(O)
new worldload
In response to Nova2000
Did anyone read my post all your answers are there for map saving
In response to Super16
Yes I did. I couldn't get it to work, and what's with the rest of it? The mob, and clicking and overlays...
In response to Nova2000
Nova2000 wrote:
Yes I did. I couldn't get it to work, and what's with the rest of it? The mob, and clicking and overlays...

That was my test hehe.