This is my whole saving code:
mob/player/proc
CreateNewCharacter()
var/char_name = input("What is the character's name?", "New character", null) 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 = ""
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?", null) 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/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", null) 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
The bold part is where I get my errors. I took this code from here:
http://www.deadron.com/Games/ByondBasicSavefiles.html
The part that is bold in my code looks like it is spaced wrong, but I can't seem to find out how it should be spaced. How I have it spaced right now gives me 2 infinite loop warnings. Does anyone what is wrong?</<></<>
Copyright © 2025 BYOND Software.
All rights reserved.