savefile help needed in Developer Help
|
|
This is the code for my savefile stuff. It sucsesfuly saves the name of the character and loads it, but It won't save or load the HP, wealth, strength, MP, and inventory that the player has gained. Whats the use of it If those arn't saved? Some one please help me. (I got this from Deadrons tutorial)
mob
Login()
icon_state = gender
var/savefile/F = new("players.sav")
F.cd = "/[ckey]"
var/list/characters = F.dir
var/newCharacterChoice = ""
var/list/menu = new()
menu += characters
menu += newCharacterChoice
var/result = prompt("Who do you want to be today?", null, "Choose a charactor or create a new one") in menu
if (result == newCharacterChoice)
name = CreateNewCharacter()
else
F.cd = "/[ckey]/[result]"
F["full_name"] >> name
return ..()
CreateNewCharacter()
var/char_name = prompt("New character",null, "What is the character's name?") as text
SaveCharacter(char_name)
return char_name
SaveCharacter(char_name)
var/savefile/F = new("players.sav")
var/safe_name = ckey(char_name)
F.cd = "/[ckey]/[safe_name]"
F["full_name"] << char_name
F["/[ckey]/[safe_name]/full_name"] << char_name
client/proc/SaveMob()
var/savefile/F = new("players.sav")
var/char_ckey = ckey(mob.name)
F["[ckey]/[char_ckey]"] << mob
client/proc/LoadMob(char_ckey)
var/savefile/F = new("players.sav")
F["[ckey]/[char_ckey]"] >> mob
mob
var/tmp/Person
Write(savefile/F)
..()
F["/players/[ckey]"] << Person
return
Read(savefile/F)
..()
F["/players/[ckey]"] >> Person
return</<></<></<></<>
|
Remove the tmp from the Person var and it will be saved for you automatically, unless you have a reason for storing it elsewhere.
If the problem vars aren't in the Person object, then you'll need to list them.
I'd also recommend instead using the new Character Handling library, which has an updated approach to saving mobs:
byond://Deadron.CharacterHandling