ID:142128
 
Code:
turf/End // this works but would like to access the savefile via the srcs name associated with the save file
icon = 'end.dmi'
name = ""
DblClick()
if(fexists("/players/[usr.ckey].sav")) // find the save file if it exists
Choosing_delete: // a label so if they choose to say "No" at the next prompt they come back here.
var/delete_choice = input("Which save file to delete?","Ending Odyssey?") in list("/players/[usr.ckey].sav","Nothing")
if(delete_choice == "Nothing")
return // does nothing but return to the title screen
else
var/delete_save = input("Are you sure you want to delete this save file?","Ending Odyssey?") in list ("Yes","No")
if(delete_save == "No")
goto Choosing_delete // goes back to all choices
return // safety return
else
fdel("/players/[usr.ckey].sav") // deletes the save file but would like to refer to the savefile by the name associated with it
usr << "You deleted your save file." // need to change it so that they see the file's name they just deleted
else
usr << "There are no Odysseys to end."
return


Problem description: The programming is fine but the only issue I have is that I'd like to be able to prompt the savefile as the users name associated with it. Like say the users name associated with the savefile is "Fred". Well, instead of showing the un-deciphered savefile text I'd like it to show "Fred" along with "Nothing".

This is my first time with even being successful with savefiles and so far I've gotten the save and load all done but not it's just this. If I'm doing something wrong let me know as well please.

The answer is pretty obvious; just use usr.key instead of "/players/[usr.ckey].sav". Then, later on in your code, generate the name of the save based on the ckey() of the key. EDIT: Or just the usr's ckey var, since it's the same thing and uses less CPU.

Also keep in mind using goto is a bad programming practice, and that if someone's name is Nothing they won't be able to delete it. It would be best to say in list()|null, then saying if(!delete_choice) instead of if(delete_choice == blah blah).
In response to Jeff8500
Well I'm going to try what you just said. Thanks for the advice on not using goto labels I kinda thought that'd be the case. I have a name check to make sure that the person at least enters a name if that's what you're talking about by the way.
In response to DragonMasterGod
Yes, you should always use while() or for() instead of goto.


And no, I didn't mean check if they entered a name. I'm saying take "Nothing" out of your list as an option and replace the whole thing with list(stuff in list)|null, because if a player has the key/name "Nothing", they won't be able to delete their file.
In response to Jeff8500
I see what you mean. Ok now this still isn't working as far as referring to the save file by it's name. I can't figure out how to refer to the file by it's name still because if I save it as the "/players/[usr.ckey].sav" that seems like a legit file name and it actually works, where as if I save it as just usr.key when I try to refer to that in the list it the whole DblClick() on the End turf doesn't work. Did you mean change the actual savefile to something like "[usr.key]" by any chance?

Just to clarify, I'm not trying to refer to the file by the users key alone, I'm trying to refer to it by the user's character's name in-game.
In response to Jeff8500
It's a very good idea, but just note your posted syntax is off. You combine 'null' with your input type, and it should also be the first (they decided to make it generate a warning otherwise):
input("...") as null|obj

If you're using a list and you don't want to use an object type filter, then you'll need to use the otherwise-optional anything input type:
input("...") as null|anything in List
In response to Kaioken
I edited the title to "Referring to a save file by the user's character's name". That's what I'm trying to do