I want it so that the IF depends on FOUR variables, that Hit1,Hit2,Hit3,Hit4 ALL equal 1, i tried
turf
Trainer1
icon = 'NPC.dmi'
icon_state = "Trainer1"
verb/Speak_to_trainer()
if (usr.Hit1 = 1),(usr.Hit2 = 1),(usr.Hit3 = 1),(usr.Hit4 = 1)
usr << "Well done you hit all the targets!"
usr << "You got some experience and money!"
usr.Hit1 = 0
usr.Hit2 = 0
usr.Hit3 = 0
usr.Hit4 = 0
else
usr << "Hit all four Targets then come back to me!"
But i get error messages :
Turf.dm:112:error: ,: expected }
Turf.dm:112:error: location of top-most unmatched {
What should I do?
ID:175564
Apr 7 2003, 9:54 am
|
|
In response to Maz
|
|
THANK YOU, IT WORKED!!!!
|
To combine multiple checks into a single if() statement, you have to use the && (and) or || (or) operators...
&& is the one you want, since it checks them all, and only returns 1 if all of the checks are true... || returns 1 if any (but not necessarily all) of the checks are true... Also, you need to use == in if() checks instead of just = ... One = sign is used to set a variable to some value... == is used to check equality...
if (usr.Hit1 == 1 && usr.Hit2 == 1 && usr.Hit3 == 1 && usr.Hit4 == 1)
Furthermore, to simplify things a bit, you can take out the == 1 bits and just do this:
if (usr.Hit1 && usr.Hit2 && usr.Hit3 && usr.Hit4)
That still checks each variable to see if it is TRUE (1) or FALSE (0)... It does it automatically if you don't supply a value to check... |
In response to SuperSaiyanGokuX
|
|
SuperSaiyanGokuX wrote:
To combine multiple checks into a single if() statement, you have to use the && (and) or || (or) operators... > if (usr.Hit1 == 1 && usr.Hit2 == 1 && usr.Hit3 == 1 && usr.Hit4 == 1) Furthermore, to simplify things a bit, you can take out the == 1 bits and just do this: > if (usr.Hit1 && usr.Hit2 && usr.Hit3 && usr.Hit4) That still checks each variable to see if it is TRUE (1) or FALSE (0)... It does it automatically if you don't supply a value to check... ----------------------------------------------------------- THANK YOU FOR YOUR WONDERFUL INFORMATION, you have both been very helpful for a lost and confused NEWBIE... |
Using if(something) checks if it is true which means 1 or anything, therefore when its 0 its nothing therefore it fails.
There can be ways to do this using || (byonds OR thing) but this way is pretty simple to understand when looking at it.
oh and return finishes your verb.