変数を使用して、それが true であると仮定することができます
local IsEverythingTrue = true
-- the **for** statement is a loop. It will allow us to operate
-- the same way on any number elements in inventory.
-- _,v stands for variables that we are going to read from inventory table
-- we can't do it directly, however; **ipairs** function will prepare it so
-- _ will hold numerical index of each element (1, 2, 3 and so on);
-- we don't use it, though, so I put in a placeholder name
-- v will hold every value, so your two-element table
for _,v in ipairs(inventory) do
-- if any value of v[2] is false, break
-- v[2] is equal to inventory[_][2]
-- if not v[2] can be written as
-- *if value of v[2] isn't true*
if not v[2] then
-- in this case, after first non-true element has been found
-- we know that not every one is true, or there is at least one false
IsEverythingTrue = false
break -- we don't have to check anything else
end
end
次に、その変数を式で使用します
if IsEverythingTrue then
-- do something
else
-- do something else
end
複数の偽で実行したい場合は、それらを数えるだけです。を先頭に追加local falseCount = 0
し、 に変更break
しfalseCount = falseCount + 1
ます。