ID:1869757
 
Code:


Problem description:So this is a problem that only makes testing easier but its annoying me. So when i test and than exit out of the game destroys any instances ive created and saves the character.

Problem 1. at first without messing with code when i tried to load and if my character was instanced id get a blank screen. Fair enough id have to start a new game because i was spawned into nothing

problem 2. To fix this i coded so that when i saved inside of a instance that my location was equal to my respawn position. Meaning that when i exited i should quickly change my location outside of instance and than save. Now when i did this without changing anything else it now disables me from pressing the load button.

The code src.loc=src.respawn prevents me from pressing my load button when it is in the save variable that happens when you exit


So, we're going to need a little more information on this.
When a player is at the start menu, are they immediately loaded into their saved character, as in /client's mob is loading their savefile upon New() or Login() ? Or is the default mob something like mob/character_handle and then that mob/character_handle has nothing going for it until the player presses New/Load and then client.mob is switched from this /mob to their saved /mob ?
DanteVFenris wrote:

The code src.loc=src.respawn prevents me from pressing my load button when it is in the save variable that happens when you exit

What is src.respawn? Are you saving turfs? If so you should not do that. A better approach would be to use locate with a tag.

Src.respawn=locate(1,1,1) lets just give that location for an example.

Respawn is just a location I can respawn a character too when he dies. But I'd like to respawn them if they exit dungeon.

Right now login() creates my title screen for it to wait for you to press new or load buttons
It loads save when you press the load button.

When you start the player has nothing going for them. Than I Just load the save. Don't beleive I create a new mob. Just the current empty mob gets all the values of the saved one
Let's talk savefiles.

Assuming your player type is /mob/player and you are overriding Write() and Read() for location saving you could simply, on Read() check if the location is valid and if not move them to a safe location.

Simply changing loc = respawn will instantly change your loc wouldn't it?

mob/player
Write(var/savefile/F)
..()
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
var/turf/t = locate(F["x"],F["y"],F["z"], FALSE)
if(t)
loc = t
else
// handle invalid location


Generally locate(1,1,1) or any other locate would return a reference to a turf, don't go be saving that.
In response to DanteVFenris
Are you able to provide the code surrounding "src.loc=src.respawn" so we can see what is and isn't going on? (Be sure to show using the DM Code(<.dm> - .) instruction). It sounds as if either the /mob isn't being Saved/Loaded properly or something is interfering with the /mob location. Ideally, you should be using Move() with a sanity check.