[Solved] Problem with logical operator "or"
Posted: Thu Oct 01, 2020 1:58 pm
I got the following setting:
I want to generate a prototype if the setting is either "enabled" or "enabled-hidden". I therefore do the following check:
From my understanding it should be possible to make this shorter with one of the following options:
The first one only fails when you select "disabled". It generates the prototype regardless.
The second one only fails when you select "enabled-hidden". It doesn't generate the prototype.
What am I doing wrong? Is this just not possible? This is not that big of a deal for the case described here, but if you have settings with 4 or more options checking all of them individually gets very messy.
Code: Select all
setting_type = "startup",
name = "spidertron-remote",
type = "string-setting",
allowed_values = {"disabled", "enabled", "enabled-hidden"},
default_value = "enabled"
Code: Select all
if settings.startup["spidertron-remote"].value == "enabled" or settings.startup["spidertron-remote"].value == "enabled-hidden" then
...
end
Code: Select all
if settings.startup["spidertron-remote"].value == "enabled" or "enabled-hidden" then
if settings.startup["spidertron-remote"].value == ("enabled" or "enabled-hidden") then
The second one only fails when you select "enabled-hidden". It doesn't generate the prototype.
What am I doing wrong? Is this just not possible? This is not that big of a deal for the case described here, but if you have settings with 4 or more options checking all of them individually gets very messy.