ID:139901
 
Code:
        Save()
set category = "Commands"
set name = "Save"
var/savefile/F = new(ckey)
Write(F)
usr << "[usr] have saved succesfully."


Problem description:

runtime error: Failed to write variable random to savefile narutobleach. The value being written was 1.
proc name: Save (/mob/verb/Save)
source file: Verb.dm,21
usr: Rich (/mob)
src: Rich (/mob)
call stack:
Rich (/mob): Save()

I get a runtime error when I save... -.-
Well technically that code is fine. i guess.

But you should not read and or write directly like you have.

its better to do.

mob
Write(var/savefile/F) //writes the file pretty straight forward
F["savefile_version"] << SAVEFILE_VERSION
..()
F["SavedX"] << x
F["SavedY"] << y
F["SavedZ"] << z

Read(var/savefile/F)
loc = locate(F["SavedX"],F["SavedY"],F["SavedZ"])
var/version
F["savefile_version"] >> version
if(isnull(version)) version = 0
..()
// var/resave //Simple var to track whether or not to save again
// if(version < 2) //If a version is less then the version noted here execute the commands that change stuff
// str = round(str * 0.4, 1) //changey stuff

client/proc/Save()
var/txtfile = file("Saves/[copytext(xkey,1,2)]/[xkey].txt")
var/savefile/F = new("Saves/[copytext(xkey,1,2)]/[xkey].sav")
F["Slot[mob.slot]"] << mob
fdel(txtfile)
F.ExportText("/",txtfile)




client/proc/Load(var/Slot)
var/savefile/F = new("Saves/[copytext(ckey,1,2)]/[ckey].sav")
F["/Slot[Slot]"] >> src.mob

In response to Midgetbuster
Thank you... I also want to ask what the difference between, client/proc/save and mob/proc/save is? Aren't they both almost the same use?
In response to NarutoBleach
in a way..

World Procs and Vars. are globalized things such as muting an OOC or making it so certain things can execute continuously.

Mob procs are specific to all mobs and are usually for AI and most player related commands.

Client procs are purely dependent on the client (client being the window)


Technically speaking its fine either way but people usually use client procs for load and save. or like me where i use world for save and client for load (since my save initiates after someone has already logged out and thus requires a globalized command)