world
name = "Egg World"
mob = /mob/LobbyPlayer
client/New()
if(usr) return ..() //reconnecting to existing mob
else
var/player_sav = "players/[ckey].sav"
if(length(file(player_sav))) //if player savefile exists
var/savefile/F = new(player_sav) //open it
F["mob"] >> usr
F["loc"] >> usr.loc
return ..() //creates a new mob if necessary
//The player is connected to this mob if they do not have a save file present.
mob/LobbyPlayer
icon = 'player.dmi'
icon_state = "move"
Login()
..()
usr << "Welcome! I see it's your first time here!"
usr << "Let's get you started!"
client.mob = new/mob/Player(usr.loc)
del src
mob/Player
icon = 'player.dmi'
icon_state = "move"
step_size = 8;
step_x = 0;
step_y = 16;
bound_x = 8;
bound_y = 0;
bound_width = 16;
bound_height = 16;
var
things = 0;
money = 0;
Logout()
var/player_sav = "players/[ckey].sav"
var/savefile/F = new(player_sav)
F << src
F["mob"] << src
F["loc"] << src.loc
del src
Problem description:
Okay, so I have a dummy mob "LobbyPlayer" set up to handle the player if they don't have a savefile present. After that, I create the actual Player mob and assign it to the client.mob. When the Player mob for that client logs out, it saves the mob. When a client tried to connect, it loads the mob.
My problem is that loading the mob doesn't seem to call New() or Login() on the mob. So for instance if I wanted in the future to change the code to
step_size = 4
You can reset step_size after calling ..() in Read(), including in Login(), but it's more appropriate in Read().
You might want to keep track of savefile versions, so you can respond to older save formats.
Also, it's unnecessary to save twice, so remove that F["mob"] << src line.