ID:149973
 
Ok I'm writing the Equip verb for /Equipment/ items, and heres one line for it, which is supposed to check to see if it can be equipped to their body, or both hands:

    if(Choice=="Body")
if(!EqObj.Type=="Body" || !usr.Body=="\[None]")
alert("This object cannot be equipped here!","Equip")
else
(equipping code here)


What i'm trying to do is this:

If they want to equip to their body, first check to see if the object can be equipped to their body and if their body isn't already equipped. If it can't, tell them, otherwise...

[edit]
heh took four tries to get this post right! :p
I think what you are looking for is &&. || acts as OR, and && acts as AND..

so try doing something like this:
if(Choice=="Body") // if you pick body
if(EqObj.Type!="Body") // if the objtype isnt "body"
usr << "Cant equip this to your body"
if(EqObj.Type=="Body") // else, equip it
//equip code


Im kinda tired from staying up all night, but i hope you get the idea.


-Rcet
In response to Rcet
What I'm looking for is "OR" :p

If I said AND, it would only tell you you coulddn't equip if there was something euipped there already AND if it couldn't be equipped by that place.
Dreq wrote:
if(!EqObj.Type=="Body" || !usr.Body=="\[None]")

The way you have it, it first evaluates !EqObj.Type. Since EqObj.Type is probably a text string, !EqObj.Type would be logical false. Then it tests (false=="Body") Well, "Body" does not equal false, so that part is false. It does a similar logic process on the right of the ||, so you end up with false || false, which is false. The if() then jumps to the else line.

Group the separate tests within parenthesis so that they are evaulated first. I also removed the ! (logical not) and instead used a != (not equal to) comparison.

if((EqObj.Type!="Body") || (usr.Body!="\[None]"))
In response to Shadowdarke
Thanks!