OS: Windows 11
Platform: VS Code
Is it possible to check two different variables against a single or multiple values in a single line?
I'm trying to use this:
if (varA or varB) == "targetValueA" or "targetValueB" then
-- rest of function
end
This doesn't work as I thought it would, obviously, but maybe you can see what I was attempting to do and suggest how you would actually perform this kind of check?
Slightly aside, but relating to this function and IF's. This function overall has multiple IF's and it's following the last IF when it shouldn't be.
Function Code
I stripped out a bunch of the extra actions so that we can focus on the IF's
local function resetReading()
if spreadSprite then
spreadSprite:remove()
end
spreadName = "Not Selected"
if currentMenuOptions and currentMenuOptions[1] and currentMenuOptions[1].value ~= nil then
actions here
end
if (gameMode or destinationMode) == "autoReading" then
print("DEBUG: resetReading Path A, gameMode = ".. gameMode.. ", destinationMode = ".. destinationMode)
actions here
end
if (gameMode or destinationMode) == "manualReading" or "titleScreen" then
print("DEBUG: resetReading Path B, gameMode = ".. gameMode.. ", destinationMode = ".. destinationMode)
actions here
end
end
Adding those print statements helped me confirm what it was doing when it shouldn't have been.
When I enter this function with a gameMode of saveOption destinationMode of autoReading, it's taking the last IF path.
I would understand this if the check I tried to make was only checking the first variable and not both, but why would it take the last IF? It's acting like it's an IF/ELSE if that makes sense.