Wow what an amazing post that needs to be part of a guide for people starting DM. Thank you so much for that information I think I understand it far better now.
In response to Ter13
Ter13 wrote:
When I call the save proc manually using a verb I get a bad output the first time.

Yep, it's a standing BYOND bug that I haven't been able to get fixed. I've reported it a few times.

Unfortunately I've never been able to reproduce the issue. It never happens for me. Originally I thought it only happened on Windows 7, but I've tested on 7 since then and it doesn't have a problem any time I test it.

For the OP, if you want to save a location and load it again, my recommendation is to override Write() and Read():

mob/Write(savefile/F)
..()
F["x"] << x
F["y"] << y
F["z"] << z

mob/Read(savefile/F)
var/sx,sy,sz
..()
F["x"] >> sx
F["y"] >> sy
F["z"] >> sz
loc = locate(sx,sy,sz)
In response to Ter13
Oh, also this warning: With savefiles, remember DM will always save everything related to what you're working with. So avoid saving a turf directly; other people's mobs may be standing on it and get dragged into your savefile. Avoid having a reference to another mob, even indirectly, that isn't stored in a /tmp var. If your mob has a turf var (like var/turf/home), make it /tmp and also be sure to use the x,y,z trick so you don't save the actual turf. If your mob has a list of friends or targets, that needs to be /tmp. Objs that keep track of their owners: Keep track by key and/or name instead.

Authors who don't take this into account often run into situations where other people's mobs start getting saved in someone else's savefile, causing a "rollback" as soon as they log in--because they end up connecting to the older mob.
Outstanding post, Ter13!
In response to Ter13
Ter13 wrote:
Hebrons, where are you getting this code example?

I keep seeing people spreading and using it, and it's badly wrong. Where are you getting it from?

been working on saving , is this better ?
mob/proc/Save_File(savefile/File)
mob/proc/Load_File(savefile/File)
mob/proc/Del_File(savefile/File)

mob/Write(savefile/File)
..()
File["x"] << x
File["y"] << y
File["z"] << z
File["name"] << name

mob/Read(savefile/File)
var{saved_x ; saved_y ; saved_z}
..()
File["x"] >> saved_x
File["y"] >> saved_y
File["z"] >> saved_z
File["name"] >> name
src.Move(locate(saved_x , saved_y , saved_z))

mob/Logout()
..()
src.Save_File()
del src

mob/Save_File()
var/savefile/File = new()
..()
File = new("savefile_data/[src.ckey]")
world.log << "call save." // check if it's calling.
Write(File)

mob/Load_File()
var/savefile/File = new()
..()
if(fexists("savefile_data/[src.ckey]"))
File = new("savefile_data/[src.ckey]")
world.log << "call load." // check if it's calling.
Read(File)

mob/Del_File()
..()
world.log << "call delete." // check if it's calling.
fdel("savefile_data/[src.ckey]")
return
Don't call Read() and Write() directly.
In response to Lummox JR
Lummox JR wrote:
Don't call Read() and Write() directly.

alright cool thanks :)
In response to Hebrons
Hebrons wrote:
alright cool thanks :)

The advice he gave was one problem out of dozens that are still present in your code. -.-

name isnt even a temporary variable
Page: 1 2