ID:170181
 
I know what your thinking... Why did I put the code here.

Well There are NO errors.

I just wanna ask someone how to Make it work.

I have this code in my game

but when I run the game... Nothing that has to do with the save file come up.... Any Suggestions?

thanks in advance

Crzylme

mob/player/proc
CreateNewCharacter()
var/char_name = input("What is the character's name?", "New character") as text
SaveCharacter(char_name)
return char_name

SaveCharacter(char_name)
var/savefile/F = new("players.sav")

// Get the ckey() version of the name to avoid illegal characters for a directory name.
var/safe_name = ckey(char_name)

// Move to the directory for this character, which is:
// /player_ckey/character_ckey
F.cd = "/[ckey]/[safe_name]"

// Storing the actual name as a value (not a directory), so we don't have to worry about what characters it has.
F["full_name"] << char_name

mob/player/Login()
var/savefile/F = new("players.sav")

// What characters does this player have?
F.cd = "/[ckey]"
var/list/characters = F.dir

// Put together the menu options.
var/newCharacterChoice = "<Create new character>"
var/list/menu = new()
menu += characters
menu += newCharacterChoice

// Find out which character they want to play.
var/result = input("Choose a character or create a new one", "Who do you want to be today?") in menu

if (result == newCharacterChoice)
name = CreateNewCharacter()
else
// We need to get the full name for this character,
// which is stored in the safefile at '/player_ckey/character_ckey/full_name'.
F.cd = "/[ckey]/[result]"
F["full_name"] >> name
return ..()

mob/player/proc/DeleteCharacter()
// You might want to add a cancel option in here somewhere, and a deletion confirmation...
var/savefile/F = new("players.sav")

// What characters does this player have?
F.cd = "/[ckey]"
var/list/characters = F.dir

// Put together the menu options.
var/list/menu = new()
menu += characters

// Find out which character they want to delete.
var/result = input("Which character do you want to delete?", "DELETING a character") in menu

if (result)
F.cd = "/[ckey]"
F.dir.Remove(result)

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/mob/player/MyPlayer // This is not auto-saved, because it is declared as tmp.

Write(savefile/F)
// Let auto-save do its thing first.
..()

// Now save the player object where it belongs.
F["/players/[ckey]"] << MyPlayer
return

Read(savefile/F)
// Let auto-save stuff read in the rest of the mob first.
..()

// Now get the player object.
F["/players/[ckey]"] >> MyPlayer
return
Crzylme wrote:
but when I run the game... Nothing that has to do with the save file come up.... Any Suggestions?

Do you have a line like this anywhere:

world/mob = /mob/player
You're abusing usr in your input() procs. By default, input() boxes are outputted to usr. You need to override that default with src. If you don't understand why, then you should read the usr lecture.