ID:147617
 
/*
When a character is created with the following coding, its variables are wiped.
*/


//Copied and Pasted for the convenience of revision.


world/mob=/mob/player
mob/player/var/
safekey
safename
mob/player
Login()Main_Menu()

proc/Main_Menu()
world<<"[src.key] logged in."
src.safekey=ckey(src.key)
var/savefile/S=new("players.sav")
S.cd ="/[src.safekey]"
var/list/characters=S.dir
var/list/menu=new()
menu += "Create New Character"
menu += characters
menu += "Delete Character"
var/selection=input("Select a character to load or start a new charater")in menu
if(selection=="Create New Character") Create_Character(src)
if(selection=="Delete Character") Delete_Character(src)
else
S.cd="/[src.safekey]/[selection]"
S["actual_name"]>>src.name
proc/Create_Character()
src.name=input("What is your name?")as text
src.safename=ckey(src.name)
proc/Delete_Character()
var/savefile/S=new("players.sav")
S.cd="/[src.safekey]"
var/list/characters=S.dir
var/list/menu=new()
menu += characters
menu += "Cancel"
var/selection=input("Select the character that you wish to delete")in menu
if(selection=="Cancel") Main_Menu()
else
alert("Are you sure that you want to delete [selection]?",,"Yes","No")
if("Yes")
S.cd="/[src.safekey]"
S.dir.Remove(selection)
Main_Menu()
if("No") Delete_Character()
Stat()
statpanel("Status")
stat("[src.name]")
proc/Save()
var/savefile/S=new("players.sav")
S.cd="/[src.safekey]/[src.safename]"
S["actual_name"]<<"[src.name]"
Do you mean it's variables are wiped when it's loaded? Because if so, there's a very simple reason; from the code you've posted, you're not saving the mob, just its name. =)
In response to Crispy
When the character creation is complete, the values in the Stat() window become null. Please run this in an enviroment to understand the issue. I have already asked several programmers who did not understand why this was happening.
In response to Xallius
Xallius wrote:
When the character creation is complete, the values in the Stat() window become null. Please run this in an enviroment to understand the issue. I have already asked several programmers who did not understand why this was happening.

They're clueless if they can't figure this one out. Nothing appears in your Stat() because src.name is never set by Login(). Login() has to call ..() or perform most of the same tasks in order to set a name and gender for your character.

And as Crispy said, this save system isn't saving anything but the name. Not especially useful.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
They're clueless if they can't figure this one out. Nothing appears in your Stat() because src.name is never set by Login(). Login() has to call ..() or perform most of the same tasks in order to set a name and gender for your character.

It does? Then I guess the reference needs an update. At the moment the default action is said to be placing the mob on the map and setting client.statobj to the mob.
In response to Jon88
Jon88 wrote:
Lummox JR wrote:
They're clueless if they can't figure this one out. Nothing appears in your Stat() because src.name is never set by Login(). Login() has to call ..() or perform most of the same tasks in order to set a name and gender for your character.

It does? Then I guess the reference needs an update. At the moment the default action is said to be placing the mob on the map and setting client.statobj to the mob.

Setting client.statobj is pretty crucial to this too actually, given that the statpanel isn't appearing. But yeah, there are several actions taken in Login().

Lummox JR
In response to Lummox JR
So the problem is isolated to my Login() proc?
Could you please give me an example of how I can fix this error?
In response to Xallius
Xallius wrote:
So the problem is isolated to my Login() proc?
Could you please give me an example of how I can fix this error?

Never ever again bump your post by deleting and rewriting it. This is very annoying as we only end up reading the same message twice. This had gone long enough for a legitimate bump.

Lummox JR
In response to Lummox JR
Fine. I will rewrite a different message but I don't see how this can help. I opened the subject for help with coding and got only replies about people discussing amongst themselves over what the Login() proc does. I restated my question as an attempt to bring it back into focus and it was in vain.
In response to Xallius
"Could you please tell me how I can rewrite my saving proc inorder to save the entire mob instead of just the name?"
(If that is the origin of my problem)
I'm new to saving/loading; not to DML.