ID:167658
 
I'm making a saving system, but I pretty much forgot how to do saving correctly.

What I'm wanting to do is have it to where, when it saves, it creates a file "[mob.ckey].sav", and then in the file, it places the name of the current mob, ie:
client/proc/Save()
var/savefile/S=new("[mob.ckey].sav")
S["[mob.name]"]<<mob


However, how would I, upon clicking an obj, get all the mobs in the savefile and then send that info to client/Topic() so that they can choose a player by clicking a link? I looked at Deadron.Characterhandling, but it is very, very large, confusing, and incredibly hard to customize for my game.



edit: Also, how would I go about doing a system for character creation where it checks if the name entered is not being used by anyone else aside from file2text()ing all the savefiles and findtext()ing through all of them for the name?
For the first part, here's the easiest way to do it (in my opinion at least, saves you some looping.)

Procedure One: Seperate Savefiles Per Character
You need to make some sort of file organization. Savefiles to go into a folder by the ckey of the person saving, and that folder should be in a "Savefiles" folder. Or however you choose to do organize it.

Anyway, you want to create an html popup and create a link based on a savefile from a list that you obtained by using flist() on the person's direction, which should be something like flist("Savefiles/[src.ckey]/")
     for(var/R in flist("Savefiles/[src.ckey]/"))
html+="<a href=?action=load;load='[R]'>[R]</a><br>"


Now we have to handle this in client.Topic(). This part is fairly easy. I think you know how to do this, but just in case you don't, I'll show an example.
client/Topic(href,list[],hsrc)
switch(list["action"])
if("load")
if(!list["load"]) CRASH("No Character Selected")
//I'm going to crash the procedure right there.\
if no character was selected, we have a huge bug somewhere

usr.client.Load("[list["load"]]")//I usually \
keep my saving and loading proc as a client.proc

else ..()


Then all you have to do is make Load() support an argument and load it based on their characters directory again.
client/proc/Load(T as text)
if(!T) return //Or ask which character they want to load
var/savefile/F=new("Savefiles/[src.ckey]/[T]")
//loading proc here


For it to look best, you may not want to give your character's savefile an extension, unless you plan on handling the string so that it takes the extension off.

Procedure Two: Single Character Allowed
Rather than useing folders for a person, use a single savefile named by their ckey. You can extract all your info from there. Of course, you wanted a link to each character. I don't think you'll want this.

Procedure Three: Multiple Characters, One Savefile
It's pretty much the same as above, but without the folders, and it uses F.cd, or just something like F["Char1"] and F["Char2"].

If you don't know about Topic(), post and someone will help you learn 'bout it.
In response to CaptFalcon33035 (#1)
Thanks, that helped alot. Actually, alot of my game so far is Topic() based. :P