ID:165325
 
I have looked at most of the saving tutorials and I still dont understand how to save a mob. Thats what I am trying to do. If anyone could Give me a code it would be very helpful. Thanks in advance ~Bobomaster~
mob
proc
Saveme() // This is the proc that saves the player
var/savefile/F = new("Save Files/[src.ckey]") // This creates a new file called your key.sav in the file Save
F["last_x"] << src.x// This stuff saves the players location
F["last_y"] << src.y
F["last_z"] << src.z
Write(F) // This Writes the file
verb // saving verb
Save() // verb
set category = "Client" // Category
usr.Saveme() // save proc
usr << "<b>You are saved.</b>"


- Miran94
In response to Miran94
Ok thanks thats exactly what I need!
In response to Bobomaster
Could I also save a whole mob this way? If so how.Thanks for any further advise.
In response to Bobomaster
Bobomaster wrote:
Could I also save a whole mob this way? If so how.Thanks for any further advise.

You are actually saving a whole mob that way. Write(F) doesn't write the savefile. It's really src.Write(F). It writes to the savefile a copy of src (the mob). The reason that x, y, and z are saved seperately like that is because they're temporary variables, and don't get saved automatically.

The savefiles section in the DM Guide explains more if you're curious: http://developer.byond.com/docs/guide/chap12.html