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?
|
May 28 2021, 10:23 pm
Best response
|
|
Here's an example of how to do that
|
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 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. |