ID:139063
 
Code:
mob
proc/LoadCharacter()
ASSERT(hasSavefile(src.ckey) && src.client)
var/letter = copytext(ckey,1,2)
var/savefile/F = new("Players/[letter]/[ckey].sav")
var/mob/M = F["mob"]
M.Move(locate(F["x"], F["y"], F["z"]))
var/list/vlist = F["verbs"]
for(var/v in vlist)
M.verbs += text2path("[v]")
M.verbs.Add(typesof(/mob/verb))
//M.client = src.client
world<<"<b><font color=silver><u>Server Information:</u></font> <font color=green>[M.name] has just connected to the server."
M.CreatePlayerName()


Problem description:

runtime error: Cannot execute null.Move().
proc name: LoadCharacter (/mob/proc/LoadCharacter)
source file: Title Screen.dm,331
usr: Raimo (/mob/BaseCamp/ChoosingCharacter)
src: Raimo (/mob/BaseCamp/ChoosingCharacter)
call stack:
Raimo (/mob/BaseCamp/ChoosingCharacter): LoadCharacter()
LoadButton (/obj/LoadButton): Click(the turf (487,5,1) (/turf), "mapwindow.map", "icon-x=26;icon-y=16;left=1;scr...")

I don't get why I have the runtime error there. I would be pleased if anyone helps me out on this.
I'm not an expert in loading and saving but I do know that you are doing it wrong...

//wrong:
var/mob/M = F["mob"]

//possibly good:
var/mob
oldmob = src
M = new/mob

F["mob"] >> M
src = M
del oldmob
Because you're telling a text string to Move, not a mob.
In response to Lugia319
Would it be correct if I would do this?
var/mob/M
M << F["mob"]
//followed by the rest here

In response to Raimo
No, F["mob"] >> M
In response to Raimo
It's backwards

EDIT: Also, sorry to be a nazi, but you seem to have an open tag in your output statement.
In response to Lugia319
Still the runtime error. o:
In response to Raimo
What is your save code like?
F["mob"] >> mob
In response to Emasym
Undefined var errors.
In response to Lugia319
mob
proc
SavePlayer()
var/letter = copytext(ckey,1,2)
if(fexists("Players/[letter]/[ckey].sav")) fdel("Players/[letter]/[ckey].sav")
var/savefile/F = new("Players/[letter]/[ckey].sav")
ASSERT(src && ismob(src))
F["x"] << src.x
F["y"] << src.y
F["z"] << src.z
F["verbs"] << src.verbs
F["mob"] << src
mob
proc/LoadCharacter()
ASSERT(hasSavefile(ckey) && client)
var/letter = copytext(ckey,1,2)
var/savefile/F = new("Players/[letter]/[ckey].sav")
F["mob"] >> src
F["x"] >> x
F["y"] >> y
F["z"] >> z
var/list/vlist = F["verbs"]
for(var/v in vlist)
verbs += text2path("[v]")
verbs.Add(typesof(/mob/verb))
world<<"<b><font color=silver><u>Server Information:</u></font> <font color=green>[name] has just connected to the server."
CreatePlayerName()


Try that.
In response to Raimo
Well yeah because you're not supposed to copy/paste, the mob variable was a reference to whatever you were using at a time that needed the mob.

In your snippet there, you're loading loc vars first, and then overwriting the complete mob (which should also contain that).

My saving/loading:
//Saving:
var/savefile/F = new("Saves/Players/[key].save")
F["mob"] << mob

//Loading:
var/savefile/F = new("Saves/Players/[key].save")
F["mob"] >> mob


And I'm not kidding you, that's everything. Location/Verbs/Anything BUT overlays really (they should be handled outside of saves)
In response to Emasym
Doesn't your save/load save the icon as well? Isn't that advised again?
In response to Emasym
Emasym wrote:
F["mob"] >> mob


His Load verb isn't under client.
In response to Lugia319
Lugia319 wrote:
Doesn't your save/load save the icon as well? Isn't that advised again?

I've mentioned in that post that overlays/underlays should be handled outside of saves.

What I do before I save is strip the icon off every overlay, and then re-apply them. I story them in a list seperately, and can add/remove them at any time.