ID:138422
 
Okay, I am trying to make it so that players can delete old characters they no longer wish to play. The problem is somehow the dirs aren't getting removed...

mob/proc/SaveMob()      {
        var/savefile/F
        var/safe_name = ckey(src.name)

        // Move to the directory for this character, which is:
        // /player_ckey/character_ckey
        F = new/savefile("save.sav")
        F.cd = "/[ckey]/[safe_name]"
        F["full_name"] << src.name
        del(F)
}

mob/proc/LoadMob()      {
        var/D
        var/savefile/F
        var/safe_name = ckey(src.name)

        // Move to the directory for this character, which is:
        // /player_ckey/character_ckey
        F = new/savefile("save.sav")
        F.cd = "/[ckey]/[safe_name]"
        F["full_name"] >> src.name
        del(F)                      // close file
}

mob
mob/chat
{
        chat1   {
        verb/delete()   {
                var/Y = prompt("Are you sure you wish to delete this character?","no") \
                in list("yes","no",)
                if (Y == "yes") {
                        var/savefile/F
                        var/obj/O
                        var/safe_name = ckey(src.name)
                        for (O in src) del(O)

                        F = new /savefile("save.sav") //creates a new file or loads one if it exists

                        F.cd = src.ckey             // create a unique directory
                        F.cd = "/[ckey]"
//                      F["name"] << null
                        F.dir.Remove("/[safe_name]")
                        del(F)
                        src << "You feel yourself slowly dissolve into nothingness..."
                        del(src)
                }
        }

                Login()
                {
                        ..()
                        var/savefile/F
                        src.name = src.key
                        F = new /savefile("save.sav") //creates a new file or loads one if it exists
                        F.cd = src.ckey             // create a unique directory
                        F.cd = "/[ckey]"
                        var/list/characters = F.dir

                        var/newCharacterChoice = ""
                        var/list/menu = new()
                        menu += characters
                        if (menu.len < 3) menu += newCharacterChoice

      // Find out which character they want to play.
                        var/result = prompt("Who do you want to be today?", null, "Choose a character or create a new one") in menu
                        if (result == newCharacterChoice)
                                var/mob/M
                                M = new /mob/PC (locate(src))
                                M.key = src.key
                        else
        // We need to get the full name for this character,
        // which is stored in the safefile at '/player_ckey/character_ckey/full_name'.
                                F.cd = "/[ckey]/[result]"
                                F["full_name"] >> src.name
                        return ..()
                }
        }
}



Now whenever I use the delete verb it *should* nuke the file dir, but it doesn't cause when you log in, you still see the old char.... Any thoughts?

-James</3></<></<>
Probably the problem is with how you are calling Remove():

F.dir.Remove("/[safe_name]")


dir is a list containing names like:

"my_subdir"
"strength"

etc.

So the '/' in your call is telling it to remove:

"/my_subdir"

But it doesn't have anything named that in the list so it fails.

Try:

F.dir.Remove("[safe_name]")