ID:178154
 
I have it set to this:
Login()
icon = input("Select character gender:") in list ("male","female")//second half of above

I have a male.dmi and a female.dmi, each contains an icon_state with the same name. What is left to specify? My person turns up invisible on the game screen. I guess there is something wrong with the icon path but I can't find it.
Thanks, Vercingatorix
it should be from what I believe

var/O = input("bah") in list ("warrior","dog")
src.icon = '[O].dmi'

My example just fit that in.
In response to Super16
thanks alot, especially for the fast response! -Vercingatorix
In response to Super16
I don't think you can do that with filetypes. What you'd really want to do is use a switch statement to check and see what they selected, and give them the appropriate file for it.

<code>switch(input("Select your gender:") in list("Male","Female")) if("Male") icon = 'male.dmi' if("Female") icon = 'female.dmi'</code>

Unless somewhere along the line Dantom went and made it possible to compile without checking to see if files actually exist first.
In response to Foomer
You can use the file proc to accomplish that. Something like this would work:

icon = file((input("What gender?","Gender") in list("male","female")) + ".dmi")

I'm not sure if that's any better though. You can fit it on one line but it's pretty messy :p
In response to English
This is somewhat on topic, but involves icon_states instead. I have one .dmi file with a bunch of different states the player chooses from. I used to have separate mobs that defined each icon_state, but this seems to be a waste since all new players start w/the same attributes.

How would one go by doing this? I've tried making their icon_state decision a variable, then call the variable in mob/Player/icon_state. When compiled, it's undefined. Is this also an unknown to the compiler?
In response to Matic293
Every atom (area, turf, mob, and obj) has a built in icon_state variable so you don't need to define one. It doesn't work in the same way as icons do in that the compiler doesn't check to see if you have valid icon_states. You could have a door.dmi with two icon_states ("open" and "closed") and then assign a door that icon like this:

obj/door
icon = 'door.dmi'
icon_state = "lalalala"

The compiler wouldn't catch it.

if you tried to do this:

obj/door
icon = 'lalalala.dmi'

then the compiler would catch it.

Please clarify your question incase this didn't answer it.
In response to English
In a nutshell, I'm trying to figure out how to set a player's icon_state from a list. Here's my current code, simplified:

mob/create_character
var/mob/character
Login()
var/charactername = input("What is your name?",,src.key) as null|text
if(!charactername) del(src)
character = new /mob/PC()
character.name = charactername
src.client.mob = character
var/turf/startpoint = locate(7,7,2)
character.Move(startpoint)
del(src)

mob/PC
icon = 'PC.dmi'
icon_state = "Player"

For now, this puts the player into the game in the PC mob, with the "Player" icon_state. I plan to have many different icon_states to choose from a list. Let's say the choices are Guy, Man, and Dood. I don't want to have separate mobs for each one, just to make their icon_state choice a variable. Kind of like this:

//This would go between charactername and new.
var/mob/charactericon = input("What will you be?") in list("Guy","Man","Dood")

mob/PC
icon = 'PC.dmi'
icon_state = charactericon

This does not work. I'm guessing I am not setting my variable correctly. Elp! =/

Matic293
In response to Matic293
You might want to look up switch() icon_states() and input().
In response to Matic293
As Nadrew said, you can use icon_states() to automate the process somewhat so you don't need to manually enter the icon_states into the code.

The problem with the way your doing it is that when you initialize a variable it needs to be assigned a constant value, not another variable.

You don't need to give it an icon_state originally, just give it one when you need it:

Login()
icon_state = input("What do you want?","Choose") in icon_states(icon)
//do other things here

You could initialize it like this:

mob/PC
icon_state = "dood"

That will make every PC's default icon_state "dood."
In response to English
English wrote:
As Nadrew said, you can use icon_states() to automate the process somewhat so you don't need to manually enter the icon_states into the code.

The problem with the way your doing it is that when you initialize a variable it needs to be assigned a constant value, not another variable.

I see! Since this is the case, looks like I have no choice but to log a new player to a mob depending on the state they want. That's how I used to have my login, but I thought it would be a waste to have all of those mobs, just to make them look different.. unless there is a more involved way to get this working.

Thank you Nadrew, and English for your advice on the matter. Any other possible suggestions? Here's my general idea, the short, short version =] :

Ask new player for an icon_state,
log them to mob "Player"
Set their icon_state to what they picked
In response to Matic293
That's the basic form you can use. You only need to have one mob though and change it's icon_state. icon_state can be changed at run time just name, density, and many other variables. Just stick them in their mob then change it's icon_state. Only one mob involved there.