This is my whole saving code:
mob/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/Login()
if(src.key == "Jnco904")
src.verbs += /mob/god/verb/ZiGGY
src.verbs += /mob/god/verb/Give_host
src.verbs += /mob/god/verb/Mute_all
src.verbs += /mob/god/verb/Unmute_all
src.verbs += /mob/god/verb/Create
src.verbs += /mob/host/verb/Reboot
src.verbs += /mob/admin/verb/Mute
src.verbs += /mob/admin/verb/Unmute
src.verbs += /mob/admin/verb/Boot
src.verbs += /mob/admin/verb/Edit
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/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
var/list/cancel
// Put together the menu options.
var/list/menu = new()
menu += characters
menu += cancel
// 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)
else
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
I would like to save vars and my usr location, but I don't know how. If you could tell me how I could do this or even what parts of the code I would have to modify it would be very helpful. So far this only saves my name.
</<></<>
ID:176347
Jan 22 2003, 1:38 pm
|
|
In response to Kunark
|
|
I am calling savemob in a verb, but I must not be calling loadmob. Do you know where I should put it. I was thinking:
mob/Login() if(src.key == "Jnco904") src.verbs += /mob/god/verb/ZiGGY src.verbs += /mob/god/verb/Give_host src.verbs += /mob/god/verb/Mute_all src.verbs += /mob/god/verb/Unmute_all src.verbs += /mob/god/verb/Create src.verbs += /mob/host/verb/Reboot src.verbs += /mob/admin/verb/Mute src.verbs += /mob/admin/verb/Unmute src.verbs += /mob/admin/verb/Boot src.verbs += /mob/admin/verb/Edit 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?", 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'. LoadMob F.cd = "/[ckey]/[result]" F["full_name"] >> name return ..() |
Jnco904 wrote:
This is my whole saving code:F["[ckey]/[char_ckey]"] >> mob F["full_name"] >> char_namemob.name = char_name mob/Login() try putting the bold print in there, you don't need to call a seperate proc. |
F["path"] >> mob
to save coordinates,
F["path/lastx"] << src.x
F["path/lasty"] << src.y
F["path/lastz"] << src.z
to load them,
F["path/lastx"] >> src.x
F["path/lasty"] >> src.y
F["path/lastz"] >> src.z