ID:2687302
 
(See the best response by Johan411.)
In the Login proc, I have it set loc to a turf which is a player spawn point turf, however if I close the game(on dream daemon) and load it back up, I keep everything besides the pos, so how can I make it so when they first join it puts them somewhere but the next time they remain their pos?
Best response
Here's an example of how to do that
mob/Player
var
Save_x;Save_y;Save_z
Login()
..()
if(Save_x&&Save_y&&Save_z)
loc=locate(Save_x,Save_y,Save_z)
Logout()
Save_x=x; Save_y=y; Save_z=z
..()
In response to Johan411
Thanks! It worked
Okay, problem with Johan's response: it'll only work if the mob stays in the world and the world stays up. Normally you'll want to delete the mob on logout, or set its key to null and move it to a null loc so it can be deleted automatically.

What you're really looking for is a way to save player info, so a basic character save/load system. You'd set world/mob to a different mob type than /mob/player, maybe /mob/loading, so it can choose a character or load one. Then you'd have save/load stuff like this:

mob
Read(savefile/F)
..()
var/X,Y,Z
F["pos_x"] >> X
F["pos_y"] >> Y
F["pos_y"] >> Z
loc = locate(X,Y,Z)
... // other tasks to do on read, like rebuilding overlays

Write(savefile/F)
..()
var/X,Y,Z
F["pos_x"] << x
F["pos_y"] << y
F["pos_y"] << z
... // other tasks to do on write

This is a very simple setup so it's a little brittle. If your maps change for instance, the old x,y,z locs might be wrong. One way to combat this is instead of saving the Z level, tag the bottom-left turf (1,1,z) of each level in each map with a unique name, and then look up the tag for locate(1,1,z) when you save. Then when you load again, use locate(the_tag) to lookup the tag you saved in place of a Z level and grab its z value.

You can take this a step further and implement versioning into your map and your saves, so if you move things around you could adjust the x,y,z coords based on when the player last saved so they're in the right place on the updated map.