ID:1907001
 
This is what I have been toying with, which is snippets from the DM guide. I have fooled with it in so many ways and returned back to the DM guide version so many times...

Usually I get the inventory and stats to save. However location has never worked for me.

Mob
Login()
icon='Player.dmi'
icon_state= "Female"
var/mob/M //m = mob
for(M)
if(M.key)
world << "[M.name] has logged in."



// usr<<browse(Rules,"window=Rules;size=500x500")
Rules()
Damagecheck()
NewCharacterSkillReset()
spawn Regen()
spawn Regencheck()





var/savefile/F = new(ckey)
Read(F)
return ..()

var {saved_x; saved_y; saved_z}
//load coordinates
F >> saved_x
F >> saved_y
F >> saved_z
//restore variables
..()
//restore coordinates
Move(locate(saved_x,saved_y,saved_z))




mob/Logout()
var/savefile/F = new(ckey)
Write(F)
del(src)

//store coordinates
F << x
F << y
F << z
//store variables
..()


Yea I know messy. This is literally taken from my raw code. If someone has a working example I can adapt from and learn from, that would be great.
That's because immediately after you call Read(F) you... return for some odd reason, meaning anything afterward isn't called.
Still wont run with that tiny fix, but thanks, it slipped past me during editing XD.

    var/savefile/F = new(ckey)
Read(F)



//load coordinates
F >> saved_x
F >> saved_y
F >> saved_z
//restore variables
..()
//restore coordinates
if(!saved_x && !saved_y && !saved_z)
Move(locate(/turf/tutorial/Spawn1))
else
Move(locate(saved_x,saved_y,saved_z))


Thats what I been toying with in the last few minutes trying to get it to default to a certain location in case of load failure. Both I keep spawning with no icon in a void.
Looks like you're deleting the source before it saves the coordinates.
Read and Write should never be called directly.
In response to Lummox JR
Lummox JR wrote:
Read and Write should never be called directly.

To be fair, the first example about savefiles in the guide calls Read and Write directly. Maybe somebody could edit that to add a warning that you really shouldn't do that...
In response to Flick
Hazordhu calls Read() and Write() directly and hasn't had any issues. It basically reads/writes all the savable variables directly to the root directory.

You can even access savefiles exactly like a list:
var savefile/s = new ("blah")
Write(s)
s["x"] = x
s["y"] = y
s["z"] = z

var savefile/s = new ("blah")
Read(s)
loc = locate(s["x"], s["y"], s["z"])
I'm going with Dan on this one.