ID:266648
 
when saving to a savefile...
does it save all the vars or do I have to tell it to save the vars??
It saves all non-global, non-tmp vars.
In response to Nadrew
Note: He never said using the Write() proc but yes if you do it does what Nadrew said. It also doesn't save const vars which there is no reason to if the value is constant.
In response to Nadrew
ok tell me if this should work for saving all mobs and making sure their owner var is saved... plus typechar...
ok
here we go...
client/proc/Saveworld(mob/M as mob)
world<<"World saving!! Lag monster coming!! Please hold."
var/savefile/F=new("Save Files/AGameofKings.sav")
for(M in world)
F<<M
F<<M.x
F<<M.y
F<<M.z
F<<M.name
F<<M.owner
F<<M.typechar


this should work right?
In response to Jon Snow
Make life easy and look at this save code.

mob/proc/Save()
var/savefile/F = new("[ckey].sav")
Write(F)
F["x"]<<x
F["y"]<<y
F["z"]<<z
F["icon"]<<icon

That's all you need for a save verb now for load

mob/proc/Load()
var/savefile/F = new("[ckey].sav")
Read(F)
var
thex
they
thez
F["x"]>>thex
F["y"]>>they
F["z"]>>thez
F["icon"]>>icon
var/mov=locate(thex,they,thez)
Move(mov)

Now for saving when ever something happens either logging out or getting kicked off or server froze..
client/Del()
mob.Save()
..()
:)
In response to Super16
why ckey.sav?!

I need to save everything even the things that don't have a user currently playing them.
In response to Jon Snow
Jon Snow wrote:
why ckey.sav?!

Because it's best to have all files in canonical format; or else you might end up with some nasty save troubles. Example:

key : Hello I'm a key

ckey : helloimakey

Using ckey will keep Windows from freaking when it trys to read the " ' " in the file name.