ID:144019
 
Code:
mob
proc
mutesave() //Save proc
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")//makes a save file
F["mute"] << src.mute
Write(F) // Writes the stored files into one
mob
proc
muteload() //Load proc
var/firstletter=copytext(src.ckey, 1, 2)
if(fexists("players/[firstletter]/[src.ckey].sav"))
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
Read(F) //Reads it
F["mute"]<<src.mute


Problem description:

I want it to save the src.mute value..But it saves ALL of the variables they have. Help me please.
Then take out the Write() proc. It helps if you know what the procs that you're calling do. =/ You should really get friendly with your local DM Reference, but to be nice:

Write proc (datum)

Format:
Write(savefile/F)

When:
Called when the object is written to a save file.

Args:
F: the save file being written to

Default action:
Write the value of each variable to a directory by the same name as the variable. Variables marked tmp, global, or const and variables which are equal to their initial value are skipped.


Hiead
In response to Hiead
Ah, I got it.
In response to Hiead
Ok...Maybe I don't have it. How can I just save it?
In response to Revojake
?
Whatcha' talkin' 'bout? The DM Ref?! If so, just hit F1 while in Dream Maker.

For your coding problem, as said, take out Read() and Write(), which are actually src.Read() and src.Write(). Always make sure you actually know what procs and operators do before using them!
You should use a list rather than a variable.
This is much better
var/list/muted
proc
MuteSave()
var/savefile/F = new("muted.sav")
if(!muted.len) muted = list()
F["muted"] >> muted
MuteLoad()
var/savefile/F = new("muted.sav")
F["muted"] << muted
world
New()
..()
MuteLoad()
Del()
..()
MuteSave()
In response to Xx Dark Wizard xX
Is there actually anything better with using a list instead of a var on the mob, which will always exist anyway therefore not eating up another object? At any case you're definitely better off with a var on the mob in the long run.
In response to Kaioken
Its more convienent.
In response to Hiead
Write(), hrmm... I've seen it but didn't really know much about it. Can you think of any major advantages to using Write() and Read() instead of just F["Mob"] << M and F["Mob"] >> M?


Just curious, maybe there's a better way to write my save/load procs:
    //SaveCharacter(mob, character name, savefile)
//Saves the current mob in a directory of the savefile based off of the character's name

SaveCharacter(mob/M, char_name, savefile/F)
if(!F) F = new ("Players/[ckey(M.key)].sav")
F.cd = "/[ckey]/[ckey(char_name)]"
F["Mob"] << M
F["x"] << M.x;F["y"] << M.y;F["z"] << M.z



//LoadCharacter(mob, character name, savefile
//Loads the character selected from ChooseCharacter()

LoadCharacter(mob/M, char_name, savefile/F)
if(!F) F = new ("Players/[ckey(M.key)].sav")
F.cd = "/[ckey]/[char_name]"
F["Mob"] >> M
F["x"] >> M.x;F["y"] >> M.y;F["z"] >> M.z
M.loc=locate(M.x, M.y, M.z)


In response to Zagreus
The latter calls the former, of course. There are obvious differences. For more info consult resources, such as the DM Guide (which you should have done in the first place, of course), which discusses this ('round here).
In response to Kaioken
Thanks for the link. I'm not that far along in the DM guide yet and didn't recall ever seeing that it had a whole chapter on savefiles. If I had, I obviously would have skimmed through that first. Please don't just assume I'm just some helpless lazy bum.

Anyway, it clears things up. Thanks.
In response to Zagreus
Zagreus wrote:
didn't recall ever seeing that it had a whole chapter on savefiles

Well, it IS the guide, so it should be obviously safe to

Please don't just assume I'm just some helpless lazy bum.

You know that I know you aren't.