ID:148319
 
I'm coding a title screen and i got this error:src.ckey:undefined var
error:ckey:undefined var
i defined them and it didn't "click in" so to say

This is the coding I used:
mob/creating_character
/proc/DeleteCharacter2()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")

F.cd = "/[ckey]"
var/list/characters = F.dir

var/CancelCharacterDeletion = "Back"
var/list/menu = new()
menu += characters
menu += CancelCharacterDeletion

var/result = input("Delete character", "Create Character") in menu

if (result)
F.cd = "/[ckey]"
F.dir.Remove(result)
if (result == CancelCharacterDeletion)
..()
else
..()
That's because ckey is not a defined var. key is what you want. If you want it to be stripped of case and special characters, use ckey(key).
In response to Garthor
now key is indefined....
In response to Garthor
That's because ckey is not a defined var.

Bzzzzt! =)

The problem is such a simple and seemingly obvious one that you'll probably be kicking yourself. =)

mob/creating_character
<font color=blue>/</font>proc/DeleteCharacter2()

The blue, bolded forward slash shouldn't be there. It's making the proc into a global proc, rather than a mob/creating_character proc. Logically, as it's a global proc there is no src - so src.ckey is obviously undefined =P

It took me a while to realise it, actually - quite a subtle mistake.

<font size=-3>Are you kicking yourself now? ;-)</font>
In response to Crispy
yea i am...lol but now i got a definition problem...DeleteCharacter2() has 2 definitions....
proc/DeleteCharacter2()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")

F.cd = "/[key]"
var/list/characters = F.dir

var/CancelCharacterDeletion = "Back"
var/list/menu = new()
menu += characters
menu += CancelCharacterDeletion

var/result = input("Delete character", "Create Character") in menu

if (result)
F.cd = "/[src.ckey]"
F.dir.Remove(result)
if (result == CancelCharacterDeletion)
..()
else
..()
and
mob/proc/DeleteCharacter2()
if i delete this one, it will have invalid proc definition...so what do i do?
In response to Crispy
Actually it WAS not a defined var, seeing as it said it wasn't defined in that proc, so I win in some strange, twisted, warped way. That's how I like it.