If statement and variables


#1

The code I added does not work so my question is, is there a way to make it work. Did I put it in wrong or is this kind of operation not possible? I looked at other topics and they seemed to focus more on numbers or not the same type of variable issue as this.

*if appearance ((Black Dragon = true) and (Red Dragon = true)) and (White Dragon = true)


#2

You have to always group parentheticals in pairs. Also, it looks like you have an extra variable . . . is ‘appearance’ set to Black Dragon, White Dragon, and so on?

In that case, you might try this:

*if (((appearance = "Black Dragon") or (appearance = "White Dragon")) or ((appearance = "Red Dragon")))

Is that what you wanted? Or are appearance and each of the dragon colours separate variables? I’m not quite clear as to what you were hoping the code would do, or which variables it’s supposed to be checking.

Lynnea Glasser’s tutorial (which is brilliantly helpful, thank you @Lglasser!) covers using multiple variables too, so you might want to give that section of the tutorial a read-through for some examples.


#3

No the appearance is one variable when I tried putting it inside the parenthesis it didn’t work, but I also didn’t set up the parenthesis like you did. Thanks for your help and the link.


#4

If you’re trying to set it up to where having your appearance defined, rather than not defined, whatever it might be, is required for the bit of code you want…

You can set it up so that when you choose an appearance, you have another variable at that point which you set to ‘true’. (I personally use 0 and 1 rather than false and true) And then put this other variable in place for appearance in the *if, like *if appearanceyes = “true”.

Then on the next line below that, indented, place another if string with the black dragon, white dragon, ect conditions. And then place whatever you want to happen if these things are so indented further on the next line. gives you a friendly thumbs-up

Example:

*if appearanceyes = 'true'
  *if ((Black Dragon = true) or (Red Dragon = true)) or (White Dragon = true)
    You are mighty, and the others shall fear you! 

Note that I’m using ‘or’ with the assumption all three dragon types won’t be true at the same time.