Hi! I have just started making a simple text-adventure/Rpg, and i'm currently trying to get the basic movement working. I decided to let the program check for specific words and move according to them, and that's the code I came up with:
As long as I have a single word to check for, it works just as intended. But once I add in multiple words for the same value, the program will allow ANYTHING to be true! How do I make the program only accept the given words?
|| is a binary operator that returns true if at least one of the operands are true. In your code the second operand is "w", which is treated as true (because it's not null), so the whole expression is always true. What you have to do is to compare the variable on both sides of the operator.