ID:144501
 
Code:
mob
proc
ChooseCharacter()
src.name = input("Please name your kombatant. ","Name input")
switch(input("Please choose your kombatant.") in list("Scorpion","Sub-Zero","Retile","Johnny Cage","Goro"))
if("Scorpion")
icon = 'Scorpion.dmi'
icon_state = "scorpion"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()
if("Sub-Zero")
icon = 'Sub zero.dmi'
icon_state = "subzero"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()

if("Reptile")
icon = 'Reptil.dmi'
icon_state = "Reptil"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()

if("Johnny Cage")
icon = 'Johnny Cage.dmi'
icon_state = "Johnny Cage"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()

if("Goro")
icon = 'Goro.dmi'
icon_state = "Goro"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()


Problem description:


I have no error in my code but, it seems that when I go to log in and choose a chracter it always gives me goro. this also happend when i only had two people to choose from and sub zero was the last on the list so it seems to be whoever is last they get that icon even though they chose a differt character. Can somone please tell me what is wrong. If you get what I am trying to say please help me.
Indent all the ifs() one tab under the switch() statement.
In response to Jp
That does not work. it just gives me inconsitant indentation errors.
In response to Dbgtsuperfreak
That means you're doing it wrong.

I assume you're indenting all the stuff under the ifs() one step, too?

Basically, you need to indent under a switch statement. As you're not, the switch() is empty, and it then runs through and runs the check if("Scorpion"). "Scorpion" is neither null, 0, nor "", and therefore returns true - so it runs the stuff inside the if(). Proceed to do the same for if("Sub-Zero"), etc. etc.
In response to Jp
please give me the code sample becsaue i do not get what u are saying.
In response to Dbgtsuperfreak
mob
proc
ChooseCharacter()
src.name = input("Please name your kombatant. ","Name input")
switch(input("Please choose your kombatant.") in list("Scorpion","Sub-Zero","Retile","Johnny Cage","Goro"))
if("Scorpion")
icon = 'Scorpion.dmi'
icon_state = "scorpion"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()
if("Sub-Zero")
icon = 'Sub zero.dmi'
icon_state = "subzero"
world << "<font color=gray size=2> -SERVER INFO- <font color = green>[src]Logged in for the first time."
usr.loc = locate(1,1,2)
Save()
In response to Jp
Thank you it worked.
In response to Dbgtsuperfreak
Now, as I mentioned to Rev earlier... do not put in repeating information in the switch for each choice, let it happen after the switch() block is done (referring to the server messag, the location change and the Save() proc... why are you keep re-entering them when you can place it where you can place it after the switch? Example:
Ex1
switch(rand(1,3))
if(1) desc="Meh"
else if(2) desc="Uh oh" //NEVER have 'else if' in a switch statement, NEVER. When switch FIRST sees an ELSE, even in an 'else if', it'll think thats the last choice (meaning if it wasn't 1, 2+3 will go to else if(2), where the if() is like the reg. if() and not th switch() if() option
if(3) desc = "This will not work, read above"
common_stuff_here
loc=locate(32,122,23323)


Think of the bytes! >_>

- GhostAnime
In response to Jp
As long as you're helping with the indentation issue, you really should fix the usr abuse in there. This is a proc, after all. (That's to say nothing of the bad HTML.)

Lummox JR
In response to Lummox JR
Wasn't paying much attention there - I actually missed both of those issues.