In response to Vash_616
Bump Again.
In response to Vash_616
Use <code>length(characters)</code> instead of <code>characters.len</code>

If the length is always zero, then one of two things is happening:

EITHER:

- base_CharactersNames is not returning a list. To test this, stick in <code>world << characters</code> on the line just after you call base_CharacterNames(). If the output is *not* "/list", then this is the problem.

OR:

- It is returning a list, but the list is empty.
In response to Crispy

Ok crispy that works but not the way i want it to.
mob/creating_character
src.CreateCharacter() //This tells the src to lookup "CreateCharacter"

proc/CreateCharacter()
var/mob/new_mob //We are declaring a new variable called "new_mob" which will be used in a little minute
var/char_name // We set a var for the characters name here and make it "null"
while(!char_name) // Here we check to see whether the characters name is null or text, if null we don't allow them in, if text, they are allowed in
char_name = input("What is your name?","Create a character") as null|text //The player makes their name here
char_name = html_encode(char_name)

if (!char_name)
// Guess they don't want to create a new character after all, so send them to choose a character.
client.base_ChooseCharacter()
return

var/ckey_name = ckey(char_name)
var/list/characters = client.base_CharacterNames()
// if (characters.Find(ckey_name))
// alert("You already have a character named that! Please choose another name.")
// src.CreateCharacter()
// return

if(length(characters))
alert("You already have a character, please delete your current account and try again","ERROR!")
return

help_text = "Which village are you from?"
var/list/villages = list(Town1")
default_value = ""
var/char_village = input(src, help_text, prompt_title, default_value) in villages
switch(char_village)
//the rest of tha shiat i didnt put for people to see here :P


I want it so when you create 1 character you cant make another and it givesu the warning sign,
        if(length(characters))
alert("You already have a character, please delete your current account and try again","ERROR!")
Just keeps me from making a character completely.
In response to Vash_616
I see now a new problem then the original eh? i thought you still needed help with that undefined var as did everyone else.
In response to XzDoG
Yes that was my mistake now if anyone can help now that would be great because as i believe i said i cant move on with my game until this is done ive been stuck for days!
In response to Vash_616
Bump!
In response to Vash_616
There is a nifty article on Byondscape about something called 'Markers'. Check it out. Then run some tests on your code. Basically, you want to ask your code questions about the 'characters' var.

Is this var a list?
Is this var null?
If it is a list, what does it contain?
If it is not a list, and it is not null, what the heck `is it?

Determining what exactly the var characters is at the time you are trying to use it will help you greatly in trying to fix the problem.

In response to Flick
The character var is supposed to be all your characters or key because i want it to make it so you can only create one character so i made the var characters to respresent you at the loading screen and tell the game you already have a character, hope that made sense.
In response to Vash_616
Well done, you completely failed to understand what Flick was saying. =) He means that you should ask your code what "characters" actually is, not that he was asking for you to tell him what "characters" is meant to be.
In response to Garthor
var/list/characters = src.CharacterList()


it still doesnt do what i want it to O_O
In response to Crispy
Bump!
In response to Vash_616
Vash_616 wrote:
> var/list/characters = src.CharacterList()
>

it still doesnt do what i want it to O_O

And you still don't know what the characters var contains.

Try putting this just under that line of code:
world << characters
for(var/V in characters)
world << V
world << characters:type
if(isnull(characters))
world << "characters is null"
else
world << "characters is not null"


Alright, that might be a bit of overkill, but the point is: I don't want to know what you think the characters var is, I wan't to see what it actually is at the time you are using it.
Many times, your perception of what the program should be diong is vastly different then what is really happening. Finding out what the true value of a var is can be invaluable to figuring out whats wrong with your code.
In response to Vash_616

/list
characters is not null
In response to Vash_616
Bump.
In response to Vash_616
Well there you go. "characters" appears to be an empty list, which is why its length is zero. It's probably because you have no saved characters. So you need to change your code so that it does something sensible when you don't have any characters.

If you do have saved characters, then you're most likely not saving them how the library expects.
Page: 1 2