ID:146724
 
Code:
mob/player/proc
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")

// 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 = prompt("Who do you want to be today?", null, "Choose a character or create a new one") 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 = prompt("DELETING a character", null, "Which character do you want to delete?") 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/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


Problem description:
Okay...
There are 27 errors... I don't know what to do...

and yes... I did get this from the basic save file in tutorials....

some one... Please help me...
Are they "iconsistent-indentation" errors?
If not, what are they and what lines are they on?
Crzylme wrote:
Problem description:
Okay...
There are 27 errors... I don't know what to do...

and yes... I did get this from the basic save file in tutorials....

some one... Please help me...


I don't know what you did to this code snippet, but it was rough. You could probably just re-download the original source you got this from and star over. If not, I was able to debug this to the point where it'll compile without errors. I can't assure you that it won't break as soon as you try running it, but at least you can try now.

Your main problem was your indentation. Much of it was very screwed up. The indentation tells Dream Maker how things are ordered and organised line by line. Without it, it's lost, and gets very grumpy and sometimes starts throwing all sorts of unrelated or misleading errors at you. Best to keep 'im happy and make sure your lines are properly indented.

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

~X
In response to Hell Ramen
Thanks for fixing it...

That was a real help

Thank you!!!!
In response to Crzylme
Uh, yeah. no prob. Just keep an eye on how you indent things. It's one of the toughest bugs to track down, mainly because of the misleading errors they tend to produce. Much luck!

~X