ID:147506
 
//When I try to load, I get the following runtime error:
//runtime error: Cannot modify null.mob.
//Any idea of whats wrong with these procs?

mob/proc/Save()
var/savefile/S=new("Savefiles.sav")
S.cd="/[src.ckey]/[src.name]"
S["data"]<<src.client.mob
mob/proc/Load(selection)
var/mob/player/character=new
var/savefile/S=new("Savefiles.sav")
S.cd="/[src.ckey]/[selection]"
S["data"]>>character
src.client.mob=character//<-error occurs here.
del(src)</<src>
[link] Read through that thread.

(edit)
Oops, that is the wrong one. Let me get the number to the one I mean...

(edit again)
Forget my last edit, something must have gone wrong with my head for a moment, that was the write one.
In response to Loduwijk
I see... so as soon as the mob is loaded, src.client becomes null because the new mob takes its key?
But I'm afraid I don't see a way around that...
How can I avoid this in my load proc?
In response to Xallius
Xallius wrote:
I see... so as soon as the mob is loaded, src.client becomes null because the new mob takes its key?
But I'm afraid I don't see a way around that...
How can I avoid this in my load proc?

mob/proc/Load(selection)
var/mob/player/character=new
var/mob/source=src // get a handle on the player's current mob
var/savefile/S=new("Savefiles.sav")
S.cd="/[src.ckey]/[selection]"
S["data"]>>character
del(source) // delete the old mob

That should work.

~X
In response to Xooxer
Thanks! It works perfectly! I have been struggling with this over the weekend... I was so desperate that I actually wrote out all of src's vars in the Saving and Loading procs...

actual previous coding:
S["Name"]<<src.name
S["Class"]<<src.class
S["Level"]<<src.level
S["EXP"]<<src.exp
S["HP"]<<src.HP
S["Max HP"]<<src.Max_HP........
Sad, huh?