ID:2028977
 
Code:
var/save_directory = "Savefiles/[src.key]/slot_1.sav"
if(fexists(save_directory))
winset(src,"loginpane.slot1text","text='Character detected in slot #1'")
var/savefile/s = new(save_directory)
var/mob/m = new
//somehow grab icon and overlays from savefile
m.screen_loc = "loginpane.slot1preview:1,1"
src.screen += m


Problem description:

I want to create a "character preview" at the login screen of my game (where the player can choose between the saved progressions they have). Unfortunately, my issue, is that I do not know how to read the necessary information from BYOND's savefiles to properly show a preview of the player's saved characters. There's a couple different methods I can think of, but the same hiccup occurs where I don't know how to go about reading the savefile in a way that will allow me to grab information.

Right now, all I know how to do is properly load a mob for the player's client to take control of (I was reading how whenever a mob with a key that matches a connected client's key, loads into the world, BYOND will automatically connect the client to it). But I was moreso wondering if there is a way to read a savefile's mob during runtime without loading the mob.

The first method I thought of is the most intuitive method, where you just read from the savefile directly with savefile["variable"] and stuff, but that didn't work since the only thing to grab from a savefile in my situation is savefile["mob"]. I don't know how to go deeper into the savefile to grab other variables.

The next method was to load the mob anyways, copy it after nulling the key variable, then deleting the loaded mob (keeping the copy to play with for the preview and stuff). But I want to do this preferably without loading a mob entirely. I understand if that's the only way, though.

And the last method, which I haven't tried yet, was to use a separate savefile to be used just for previewing the saved character's appearances for the preview purpose, so I can do the first method without having to delve deeper into the savefile through some awkward manner (most likely file2text() and stuff).
After trying out the third method, I have successfully retrieved all of the info that I wanted, however, my issue is now that when I put up the player's mob to the screen, it just appears as a black square on the map element I screen_loc it to. I'm not at all sure how to fix that.

EDIT
After updating to build 510, it's no longer a black square. It's just blank. Nothing happens when I screen_loc a mob and add them to the client's screen.
//this code no longer works
client/New()
..()
src.mob.screen_loc = "previewmap:1,1"
src.screen += src.mob
why don't you just have mini map elements for each save slot and load each characters save to those maps and make em locked so they cant do anything
In response to Mastergamerxxx
I am using map elements to display a character preview for the player per character they have saved. I'm not sure what you are trying to say, exactly, given such a short response.

The goal here was to interact with the savefiles for the players' characters without having to load their mobs and subsequently have a mess of mob/Login() being called. That's just horribly inefficient and ugly if you ask me.

I was trying to get Maximus_Alex2003 to respond to me in another thread, telling me about how he accomplished his way of doing this, but he has yet to do so. I also cannot find anything regarding this particular problem or my most recent problem development on the forums. That is why I am here, and why I am asking these questions.
In response to Demonking2002
Is that even valid syntax? I don't think you can assign screen_loc to a mob. What you want to do is get the mob's appearance and assign it to an object. Then assign it a screen loc and add that object to "previewmap"
In response to GreatPirateEra
It compiles perfectly fine. And screen_loc is a movable atom variable so it should work, unless there's something within BYOND that says you can't use mobs.

EDIT
Also, I changed it up to use an obj instead of the client's mob, and the result is still the same. Nothing shows up.
In response to Demonking2002
Your code isn't actually taking into account the mob's appearance. You're calling it as soon as the client is created, meaning you can't possibly have gotten all that information. You should be doing this in Login() right after you extract the mob's appearance and any other related information in that save slot that you want to display
In response to GreatPirateEra
If you look at my original post, I wasn't using the client's mob...
In response to Demonking2002
Your original post made zero sense because you were making a new instance of a mob when you could just use your current mob. Not to mention that you really don't want to make a mob when you can just use an object with the mob's appearance. It's irrelevant anyhow, as you posted another snippet, and I responded to that one.
In response to GreatPirateEra
Sorry for the confusion. Like I was saying, I was trying to get a method where I didn't have to load mobs from savefiles just to grab their appearances for a quick preview. I found that solution, only nothing gets displayed in the map element I am putting it out to. Do you know of any reason why this would happen?
In response to Demonking2002
Yes. You need a basic saving and loading system. Save the mob's appearance for that slot and store it somewhere. You can use a list to store and update each slot's appearance. In your Login(), retrieve the list you saved your characters in from your savefile(the list should only contain the appearance) and create a new object. Set the object's appearance to the list for each slot. Add that object to the client's screen in the preview map for each slot.
In response to GreatPirateEra
I did not know that appearance was a variable I could use. That's news to me. And that was my problem the whole time. I was trying to use icons this whole time rather than just using the appearance. My code works now, and yes, it's in client/New() and not mob/Login() since I am not messing with the newly connected client's mob at all.

Thank you very much for the help. I greatly appreciate it.
client
proc
save_proc(var/n)
var/directory = "Savefiles/[src.key]/slot_[n].sav"
if(fexists(directory))
fdel(directory)
var/savefile/s = new(directory)
s["mob"] << src.mob
s["app"] << src.mob.appearance //This one line changed everything, haha

//and then elsewhere, I have...
client
New()
..()
winset(src,"default.child1","left=loginpane")
src.verbs += typesof("/client/login/verb")

//BYOND member benefit - more than one saved character

var/save_directory = "Savefiles/[src.key]/slot_1.sav"
if(fexists(save_directory))
var/savefile/s = new(save_directory)
winset(src,"loginpane.slot1text","text='Character detected in slot #1'")
var/obj/m = new
m.appearance = s["app"]
m.screen_loc = "slot1pre:1,1"
src.screen += m
else
winset(src,"slot1text","text='No character detected in slot #1'")


OH! Also! screen_loc does NOT support the "pane.element:x,y" format. It'll only work with "element:x,y"
In response to Demonking2002
Oops. I didn't notice that you had done that. Yeah, it's documented that you only need to include the element id. But I'm glad you figured it out!