ID:2410694
 
(See the best response by Nadrew.)
Code:
mob
proc
Load_Player()
if(fexists("Savefiles/[ckey].sav"))//Checks in save files if the save file is there.
var/savefile/F = new("Savefiles/[ckey].sav")//creates a variable F
Read(F)// Reads the Save file.
var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
F["Icon"] >> src.icon
var/destination = locate(last_x, last_y, last_z)
loc = destination


return 1
else
return 0

Save()
/*for(var/shadow/SH in underlays)
underlays -= SH
del SH*/


var/savefile/F = new("Savefiles/[ckey].sav")
Write(F)
//GenerateShadowMob2(src,SOUTH)
return 1


Read(var/savefile/F)
..()

Write(var/savefile/F)
..()
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z
F["Icon"] << src.icon
F["User"] << User


Problem description:

I am getting this error:

runtime error: cannot append to list
proc name: Read (/mob/Read)
source file: System - Save & Load.dm,34
usr: (src)
src: Joel (/mob)
src.loc: null
call stack:
Joel (/mob): Read(Savefiles/zoblod.sav (/savefile))
Joel (/mob): Load Player()
Joel (/mob): Access()

So can you guys help me see what i am doing wrong. And as well nothing happens when i try to load the player the screen just freezes.

You can remove your Read proc entirely.
You can replace your Write proc with this:
mob
Write(var/savefile/F)
F["last_y"] << y
F["last_z"] << z
F["last_x"] << x
F["Icon"] << src.icon
F["User"] << User
. = ..(F)
return .


btw.. don't save the icon to the savefile
Best response
. = ..(F)
return .


Is actually redundant, when you call ..() it passes all of the same arguments in the same order.

return .


Is going to happen regardless, and you're just adding needless instructions. Write() doesn't have a return value, so setting . to ..() isn't actually doing anything.

Calling ..() alone is fine, it just depends where you call it.

As for the original error, that tends to happen when you're trying to save or load a value that isn't valid, usually a variable that no longer exists or is trying to modify a variable it can't modify. The issue with using the Read()/Write() method of saving comes down to losing control over what gets saved and loaded, and loses the ability to find exactly what's going wrong if something does go wrong (as you only have the read or write action giving an error, not a specific thing).

You'll likely need to use ExportText() to view the file's contents as raw text to see if you can figure out what data isn't correct.

And as NSBR said, you really shouldn't be saving raw icon data, but instead saving the values needed to rebuild that icon when the data is loaded. Saving raw icon data not only bloats your savefiles by a ton, it makes them far more prone to corruption.
Thanks so much for the tips, i will implement them tonight. Are there other guides besides the standard guide for this programming language? Or someone to tutor me in the more complex functions of the language.
There's a whole section of the site for those resources :)
Thank you!
You're right there were some unnecessary stuffs saved in the save files there were even turf locations LOL