ID:144256
 
Code:
mob
Login()
switch(input("What chararcter class do you wish to be?") in list ("Knight", "Wizard"))
if("Knight")
src.ChooseCharacter()
if("Wizard")
src.ChooseCharacter()


proc
ChooseCharacter()
if("Knight")
icon='Players.dmi'
icon_state="Knight"
loc = locate(1,1,1)

if("Wizard")
icon='Players.dmi'
icon_state="Wizard"
loc = locate(1,1,1)


why when i pick knight it shows the wizard icon:

mob
Login()
var/choice=input("What chararcter class do you wish to be?") in list ("Knight", "Wizard")
src.ChooseCharacter(choice)


proc
ChooseCharacter(var/choice)
icon='Players.dmi'
switch(choice)
if("Knight")
icon_state="Knight"
if("Wizard")
icon_state="Wizard"
loc = locate(1,1,1)
In response to A.T.H.K
but why is it doing that though
In response to FragalaP
Because every time that ChooseCharacter proc runs, both
            if("Knight")

and
            if("Wizard")

are 'true'. So it's doing both chunks of code contained in the if() statements, running the wizard one last, so the icon_state is always set to wizard.

Basically your code is doing this:
Hmm... Does the text string "Knight" exist? If so, set icon_state to knight!
Does the text string "Wizard" exist? If so, set icon_state to wizard!

You need to check it against a variable. I recommend using a method like ATHK showed you (passing the variable in as an argument), but remember he spelt "switch" wrong in his post, so make sure that's right.
In response to Elation
Thats a lil trick so if he copy/pastes it.. yea trick.

Sorry i was rushing ill fix it :P