ID:177137
 
Could someone please give me the code for a mapsave proc?
Hello? Anyone listening?
In response to Hazman
Mapsaving isn't a one-way thing. It can be very complicated depending on exactly what you want included, and how you want it to be used in regards to reading the saved information, whether it be for loading or else... Maybe you should be a little more specific as to what you need to know, or give us a little code to work with?

-Kosh
In response to Koshigia
Let me make it more simple. I need to save 2 variables. One is a universal variable (time) and the other is an object variable (Lock). I need to save (Lock) when the user runs a verb (Change_Locks) and I need (time) saved on command (eg by a verb or proc). That make it any simpler?
In response to Hazman
AHEM.
In response to Hazman
Hazman wrote:
Let me make it more simple. I need to save 2 variables. One is a universal variable (time) and the other is an object variable (Lock). I need to save (Lock) when the user runs a verb (Change_Locks) and I need (time) saved on command (eg by a verb or proc). That make it any simpler?

Ah. Yes, it does. (And thanks for waiting before bumping it; you chose a good time frame to do so.)

Saving an entire map of turfs is indeed a complicated process, as I've recently discovered myself. However, if you're only saving a global var and vars for other objs or characters, it's not as bad. Your save proc would look something like this:
var/starttime=0   // ticks elapsed in previous sessions

proc/WorldSave()
var/savefile/S=new("world.sav")
S["time"] << (starttime+world.time)
// save all objs
for(var/obj/O in world)
S << O
// save characters
for(var/mob/M in world)
if(M.key) M.Save()

proc/WorldLoad()
if(!fexists("world.sav")) return
var/savefile/S=new("world.sav")
S["time"] >> starttime
// load all objs
for(var/item in S.dir-"time")
var/obj/O = new
S[item] >> O

mob/proc/Save()
var/savefile/S=new("characters/[ckey(key)].sav")
S.cd="/[ckey(name)]"
S["x"] << x
S["y"] << y
S["z"] << z
S << src

mob/proc/Load(character)
var/savefile/S=new("characters/[ckey(key)].sav")
if(!(character in S.dir))
client << "[character] was not found in your save file."
return
S.cd="/[ckey(character)]"
var
tx;ty;tz
S["x"] >> tx
S["y"] >> ty
S["z"] >> tz
S >> src
loc=locate(tx,ty,tz)

Lummox JR
In response to Hazman
Jeezy pete.
proc/mapsave()
for(var/atom/A in world)
world.log << "Atom [A] in [A.x],[A.y],[A.z] pooped its pants."

world/New()
mapsave()
In response to Lummox JR
Nice mapsave there, but I still have my origional vars out of place. All I need is a simple script that saves [lock] to the savefile under a directory [doors]. I'd be able to work off that to produce a [time] save proc, to.
In response to Lord of Water
is thisfor real, this seems too simple, Is LoW correct on this matter at all? It looks WAY too simple...

Erm... I've been trying to work something like this, and every time I end up with a 400 line process...
In response to Ter13
400 lines? I've found a system to do it in 14.

(Of course, it only saves objects, but still...)