ID:148541
 
Could someone tell me what's wrong with this code? It keeps asking me for my name, and doesn't load the mob after I create a character and save.
client
var
active_player = 0
proc
Save_Mob()
var/savefile/F = new("players.sav")
var/char_ckey = ckey(mob.name)
mob.tempx = mob.x
mob.tempy = mob.y
mob.tempz = mob.z
mob.temp_dir = mob.dir
F["[ckey]/[char_ckey]"] << mob
active_player = 1
Load_Mob(char_ckey)
var/savefile/F = new("players.sav")
F["[ckey]/[char_ckey]"] >> mob
mob.x = mob.tempx
mob.y = mob.tempy
mob.z = mob.tempz
mob.dir = mob.temp_dir
Create_New_Mob()
mob.name = input("What is your name?","Character name") as text
mob.icon_state = input("What color are your clothes?","Clothing Color") in list("Red","Orange","Yellow","Green","Blue","Purple","Black")
Save_Mob()

and my login proc:
        Login()
if(client.active_player == 0)
client.Create_New_Mob()
else
client.Load_Mob()
..()
I added these test verbs and when I use the load verb, the map area goes black.
Load()
client.Load_Mob()
Save()
usr << "You have been saved."
client.Save_Mob()

P.S. the Save() verb is a test 'cause I plan on using save points
In response to Delita12345
Could someone please help? This is a very important topic to me and I'd really like to figure out what I did wrong so I can code a savefile structure on my own.
I think the problem is that you've defined mob/Login() to call client.Load_Mob(), but instead this should be defined for a subtype like /mob/start or some such, which should also be the default world.mob that players use when they first log in.

Basically what's happening is that when client.Load_Mob() loads mob, it also loads the player's key. That instantly connects the client to that mob, which calls Login() for the new mob, which calls client.Load_Mob(), and the cycle begins again.

Lummox JR
In response to Lummox JR
So how should i fix it?