mob
Write(savefile/f)
..()
src.x>>f["x"] //<-- line 6
src.y>>f["y"]
src.z>>f["z"]
Read(savefile/f)
var x,y,z
x<<f["x"]
y<<f["y"]
z<<f["z"]
src.Move(locate(x,y,z))
mob/proc
Save()
var/savefile/f=new("saves/[src.ckey]/mobs.sav")
var/cname=cKey(src.name)
f["[cname]"]<<src
Load(cname)
var/savefile/f=new("saves/[src.ckey]/mobs.sav")
if(!fexists(f)) return
client.mob<<f["[cname]"]
PlayerList()
var/savefile/f=new("saves/[src.ckey]/mobs.sav")
return f.dir
mob/Choosing
Login()
CHOOSE
switch(input(src,"Welcome! What do you wish to do?") in list("New Game","Load Game","Quit"))
if("New Game")
Create()
if("Load Game")
var/savefile/f=new("saves/[src.ckey]/mobs.sav")
if(!fexists(f))
alert(src, "No savefile...")
goto CHOOSE
var/list/players=PlayerList()
var/choice=input("Which character do you want to load?") in players
Load(choice)
if("Quit")
Problem description:
I get a problem of "bad input src" during runtime at line 6. This code most likely stinks and everyone will be having ulcers looking at it. Saving systems aren't my strong point.
Well, among other problems. But I'm not in the mindset to sit and write a long post, so I'll address this problem exclusively.
When reading and writing with savefiles, you use the << and >> operators with the savefile part as the left operand, and the variable as the right operand. What this means is that, instead of something like this:
X >> f["x"]
you would do this:
f["x"] << X
As always, data "flows" in the direction of the operators, so the above mentioned example would write to the savefile (with the data in X "flowing" to the savefile), and this would read to X:
f["x"] >> X
Hiead