however, when attempting to apply it to my rpg, it didn't want to work.
Can any of you figure out what's wrong with it?
Code:
mob/player/proc
CreateNewCharacter()
var/char_name = input("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
mob/player/Login()
var/savefile/F = new("players.sav")
F.cd = "/[ckey]"
var/list/characters = F.dir
var/newCharacterChoice = "<Create new character>"
var/list/menu = new()
menu += characters
menu += newCharacterChoice
var/result = input("Who do you want to be today?", null, "Choose a character or create a new one") in menu
if (result == newCharacterChoice)
name = CreateNewCharacter()
else
F.cd = "/[ckey]/[result]"
F["full_name"] >> name
return ..()
mob/player/proc/DeleteCharacter()
var/savefile/F = new("players.sav")
F.cd = "/[ckey]"
var/list/characters = F.dir
var/list/menu = new()
menu += characters
var/result = input("DELETING a character", null, "Which character do you want to delete?") in menu
if (result)
F.cd = "/[ckey]"
F.dir.Remove(result)
Problem description:
it's supposed to bring up a prompt that will allow you to choose either create a new character, load a character, or delete a character. I get no errors when compiling, but no promp will show when running a test.
So try this:
Instead of
That should work. The biggest problem in the code you provided is that mob/player/Login() isn't really called when the player logs in, mob/Login() is called.