ID:144040
 
Code:
    Login()
usr.verbs -= typesof(/mob/verb/)
usr.density = 1
usr.canbuild=0
usr<<"Welcome to [world.name]!"
inpat
switch(input("What do you want to do?")in list("Make new character", "Continue with old character"))
if("Make new character")
switch(input("Are you sure? If you have an old character, it will be erased.")in list("Yes", "No"))
if("No")
goto inpat
if("Yes")
var/savefile/E = (ckey)
del(E)
var/savefile/F = new(ckey)
Read(F)
usr.name=(null)


Problem description:
It seems that calling Del(E) to delete the previous save file doesn't work. I'm sure I'm just using this wrong. I'd appreciate some clarity on this situation. This is the runtime error I recieve when trying create a new character:

runtime error: bad del
proc name: Login (/mob/Login)
usr: the character (/mob/character)
src: the character (/mob/character)
call stack:
the character (/mob/character): Login()
First, E isn't actually a savefile. You set it to equal "ckey", which is a text string. You probably want new(ckey) instead. Second, instead of using del(), you can use fdel() to delete a file. So fdel(name_of_savefile) should probably work, without the need to create an E savefile in the first place.

On an unrelated note with your code, usr isn't totally safe to use in Login() procedures, so you might want to think about changing that.
In response to Jon88
What would I use, src? And, your save file is named your key. So delete fdel(ckey) should work correct?
In response to Jon88
Jon88 wrote:
On an unrelated note with your code, usr isn't totally safe to use in Login()

And also, if already, don't use goto, use proper looping constructs. Also doesn't matter much but you shouldn't use needless extra parenthesis either, they're not needed very frequently, mostly in specific cases. Not in a simple var assignation with only 1 operator to begin with, of course. It doesn't affect the code, but its less & faster typing. >_>