ID:147116
 
Hi. I'm a returning BYONDer. Some of you might know me from DBLive. I'm back now, and ready to start a new game. I've encountered a problem with a basic saving/loading problem. Here's what I have so far.

The error is the loading. As you may or may not know, my character mob is /mob/PC. Listed below is the error and source code.
------------------------------------------------------------
mob
verb
Save_Character()
set name = "Save"
set category = "Options"
src << "Connecting to server..."
sleep(10)
var/S = "savedfiles/[src.ckey].sav"
if(fexists(S))
switch(alert("You already have a saved character. Do you wish to overwrite?","Dragonball Live 2","Yes","No"))
if("Yes")
var/savefile/F = new("savedfiles/[src.ckey].sav")
F["cname"] << name
F["cmob"] << src.client.mob
src << "Character successfully saved."
else if("No")
return
else if(!fexists(S))
var/savefile/F = new("savedfiles/[src.ckey].sav")
F["cname"] << name
F["cmob"] << src.client.mob
src << "Character successfully saved."
proc
Load_Character()
var/mob/PC
var/S = "savedfiles/[src.ckey].sav"
if(fexists(S))
var/savefile/F = new("savedfiles/[src.ckey].sav")
F["cname"] >> name
F["cmob"] >> PC
src.client.mob = PC //LINE 53
..()
else if(!fexists(S))
alert("There is no current saved characters.","Dragonball Live 2")
------------------------------------------------------------

runtime error: Cannot modify null.mob.
proc name: Load Character (/mob/proc/Load_Character)
source file: dblive{charhandle}.dm,53
usr: DBLive (/mob/TitleScreen)
src: DBLive (/mob/TitleScreen)
call stack:
DBLive (/mob/TitleScreen): Load Character()
Load Character (3,7,1) (/turf/Title_Screen/Load_Character): Click(Load Character (3,7,1) (/turf/Title_Screen/Load_Character))
</<></<></<></<>
You should encase your code in DM tags, it hurts my eyes looking through the different bright colors. Also, I might be wrong but isn't saving the name a little redundant? All of the variables in the mob would be saved. The runtime says that src.client is null, so you might want to show us how you are calling the procedure.
In response to SSJ2GohanDBGT
the save verb is called from the mob/PC

mob/verb/Save_Character()


the load proc is called from a turf.Click()

turf/TitleScreen/Load
Click()
usr.Load_Character()
In response to ZDarkGoku
runtime error: Cannot modify null.mob.

Somewhere you're checking something.mob, but something is null.
In response to Garthor
I was just messing around and solved the riddle. >_<. Thanks for your guy's help anyways.
In response to ZDarkGoku
I really hate it when someone says "thanks anyway" (I hate it even more when they use non-words such as "anyways") even when the only reason they figured it out was because they got help.
In response to Garthor
Garthor wrote:
I really hate it when someone says "thanks anyway" (I hate it even more when they use non-words such as "anyways") even when the only reason they figured it out was because they got help.

Actually, no-one mentioned about what I did to fix it.

The line <font color=blue>src.client.mob = PC</font> was useless to be in that spot.

Last, I said "thanks" which means "thank you". And if you don't want that, then I take it back.
In response to ZDarkGoku
Looking back at the code, I don't see how its useless to be there. You're defining a variable as a mob(which is linked to nothing) and placing the info from the file onto that mob. Anyhow, I guess it doesn't matter since the problem is fixed.
In response to SSJ2GohanDBGT
I know. it still loads with no errors when the line is added. But hey, I can't live with red text on the chat screen lol.
In response to ZDarkGoku
The problem was that when you load a new mob, it loads the key variable, and when a new mob pops up with a key variable the same as client.key, you get dropped into it. Because you've changed mobs, src.client is null. Also, you don't need ..() there.