ID:154719
 
I have a skin that once you enter your username and password, it will show you a screen where you can do typical things, such as create, load, or delete a character. Now, I was wondering how would I go about putting the icon from a savefile, and putting it onto a label? Or how would I make a mob that I could place into a grid to show the mob and the name. I have tried making a new mob, and placing the mob from the savefile on to the new mob. However, it loads the savefile rather than loading it on to the new mob. I have tried a few different ways, and I have run out of ideas. Any help would be greatly appreciated.
For example... I try to do something to this effect:
mob
proc
show(var/A)
if(fexists("Saves/[A]/Slot 1.sav"))
var/savefile/F = new("Saves/[A]/Slot 1.sav")
var/mob/B = new()
F["icon"] >> B.icon
winset(src,"Characters.grid1","current-cell = 1")
winshow(B,"Characters.grid1")

And it reads the icon from the savefile as null.
Doing other variations of code to try to get something towards that effect, I have gotten different errors. Things like Bad client, and others that have been put down the list.
Once again, any help would be greatly appreciated.
In response to Koriami
Bump
In response to Koriami
Show us how you're saving the icon.
In response to DarkCampainger
mob/proc
Save()
if(client)
var/savefile/F = new("Saves/[Username]/Slot [Slot].sav")
F["mob"] << src

client/proc
Load(var/a,var/b)
if(fexists("Saves/[a]/Slot [b].sav"))
var/savefile/F = new("Saves/[a]/Slot [b].sav")
F["mob"] >> mob
Loggingin = 1
world<< "[src] has logged in"
mob.namehud = 0
mob
Write(var/savefile/F)
..()
F["x"] << x
F["y"] << y
F["z"] << z
F["Slot"] << Slot
F["step_x"] << step_x
F["step_y"] << step_y
F["dir"] << dir
F["ICON"] << icon
F["OVERS"] << overlays
F["Name"] << name
Read(var/savefile/F)
..()
loc = locate(F["x"], F["y"], F["z"])
step_x = F["step_x"]
dir = F["dir"]
step_y = F["step_y"]
Slot = F["Slot"]

and then when I try to take the icon from the file, I do this:
mob/proc
Show_Characters(var/A)
if(fexists("Saves/[A]/Slot 1.sav") //A is the username
var/mob/M = new/mob
var/savefile/F = new("Saves/[A]/Slot 1.sav")
F["ICON"] >> M.icon
F["OVERS"] >> M.overlays
F["Name"] >> M.name
winset(src,"Character Screen.grid","current-cell=1")
src<< output(M,"Character Screen.grid")

and usually what happens is either:
A. Src loads the entire savefile, instead of taking the icon and overlays from the file or
B. Nothing shows up in the grid, giving me the impression that it is not reading the variables from the savefile, leaving the name, icons, and overlays as null. But the mob would still be placed in the grid.

I have tried 4 or 5 different ways to do this, and I have gone so far as to save an extra .txt file with the icon and name in it, and using the params2list() proc to take it out of the file and place it on the icon. However, I cannot seem to find a way to get this to work.
In response to Koriami
The issue is that within the datum Write() process, the current directory of the savefile is set to a sub-directory just for that datum. So when you later try to access "ICON" or "Name" from the base directory, it can't find it. The simplest solution is to move the writing of those particular values (ICON, OVERS, Name) into the mob/Save() process.

mob/proc
Save()
if(client)
var/savefile/F = new("Saves/[Username]/Slot [Slot].sav")
F["mob"] << src
F["ICON"] << icon
F["OVERS"] << overlays
F["Name"] << name