ID:150164
 
Hello im currently working and working on my game. I asked for help before on a code iwas using to check speels. Well many people wrote back and helped me alot but now i have a little more trouble with it. I know there must be some thing missing such as the format i have it set in or such here take look...First i tried this :

darktest()
set category="Magic-Transformations"
if(usr.icon_state=="humanmale"|usr.icon_state=="elfM")
flick("dark1",src)
icon_state="darktest"
if(usr.icon_state=="darktest"||usr.race=="elf"||usr.sex=="Ma le")
flick("dark1",src)
icon_state="elfM"
if(usr.icon_state=="darktest"||usr.race=="human"||usr.sex==" Male")
flick("dark1",src)
icon_state="humanmale"

This code compiles right and such but theres one big problem lol. No matter what race or sex you are the code will always take the last "if" in the proc making you a human if you were suppose to be an elf. I tried making a seperat verb but was having toruble with that also, i didn't want to have a seperate verb though. But i think i could always have a specific verb given to each race and sex if needed. Any help with the above code would help much thank you also i thougt maybe usingthe "else" but it didn't seem to work either. Again thank you for all your help.

-kalzimere


Try using && (and) instead of || (or).
In response to Nadrew
yeah i try using the && once before ill try again and report back to you thanks nadrew

-kalzimere
Kalzimere wrote:

Any help with the above code would help much thank you also i thougt maybe usingthe "else" but it didn't seem to work either. Again thank you for all your help.

Your instincts were correct here. If you only want one branch to execute, you should use if-elseif-else, eg:
mob/verb/whatami()
if(gender=="male")
usr << "You are a hairy brute"
else if(gender=="female")
usr << "You smell like dewdrops and flower petals"
else
usr << "I don't know what you are, but I like it!"


Without the 'else' clauses, each branch would execute, one after another.

In response to Kalzimere
ok i tried the new code here:

darktest()
set category="Magic-Transformations"
if(usr.icon_state=="humanmale"|usr.icon_state=="elfM")
flick("dark1",src)
icon_state="darktest"
if(usr.icon_state=="darktest"&&usr.race=="elf"&&usr.sex=="Ma le")
flick("dark1",src)
icon_state="elfM"
if(usr.icon_state=="darktest"&&usr.race=="human"&&usr.sex==" Male")
flick("dark1",src)
icon_state="humanmale"

I placed the && in place of the ||. The spell works but when clicked again nothing happens. This is sort of a new area for me lol. Thanks so far for help nadrew.

-kalzimere

In response to Kalzimere
Look at Tom's post, the last if should be else and the second one should be else if.
In response to Tom
Ok toms adviced probably works lol. But i think im still not setting something up right because it still won't work. But with all your help i believe im getting close and closer. Thanky you again and heres what my code looks like now:
darktest()
set category="Magic-Transformations"
if(usr.icon_state=="humanmale"|usr.icon_state=="elfM")
flick("dark1",src)
icon_state="darktest"
else if(usr.icon_state=="darktest"&&usr.race=="elf"&&usr.sex=="Ma le")
flick("dark1",src)
icon_state="elfM"
if(usr.icon_state=="darktest"&&usr.race=="human"&&usr.sex==" Male")
flick("dark1",src)
icon_state="humanmale"

Oh yeah there are going to be more then 2 races so do i still make the lst one else if so then i think all i got to do is make the last one an else and it should work.
-kalzimere