If statement and variables

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)

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.

5 Likes

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.

1 Like

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.