world
mob=/mob/player
mob/player
icon='icons.dmi'
icon_state="player"
turf
icon='icons.dmi'
snow
icon_state="snow"
mob/Login()
if(LoadFile())
else
loc=locate(1,1,1)
mob/Logout()
SaveFile()
mob/proc/SaveFile()
if(fexists("Players/[ckey].sav")) fdel("Players/[ckey].sav")
var/savefile/F=new("Players/[ckey].sav")
F["LastX"]<<src.x
F["LastY"]<<src.y
F["LastZ"]<<src.z
mob/proc/LoadFile()
if(fexists("Players/[ckey].sav"))
var/savefile/F=new("Players/[ckey].sav")
loc=locate(F["LastX"],F["LastY"],F["LastZ"])
return 1
Problem description:
In the process of writing my own code from scratch, I discovered two key issues:
I am currently unable to utilize the world/New() or mob/New() procedures to create a new mob and transfer control of it to the user's client. While I have successfully implemented the blocking of turf generation from world/New(), I am also attempting to spawn a new mob as part of this process.
When using mob/Login() to create a new mob and swap client.mob, it results in the spawning of infinite mobs. ALSO I adapted Falacy's save/load tutorial to match my own coding style and found that it works with just var/savefile/F = new("[ckey].sav"). However, I had to include return 1 at the end of the Load procedure for it to function properly.
The loop you're experiencing is because Login/Logout are called when you switch mobs.
I would advise switching to a different tutorial. Saving/loading xyz coords should be done inside of Read and Write anyway, not outside.