-- No parser: compare the text in lower case
local str_value = "True"
local bool_value1 = str_value:lower() == "true"
-- bool_value1 = true
-- Several words count as true: a set of words
local true_words = {["true"] = true, yes = true,
["1"] = true}
local str_answer = "yes"
local answer = str_answer:lower()
local bool_value2 = true_words[answer] == true
-- bool_value2 = true
-- Trap: the text "false" is true in a condition
local str_false = "false"
local bool_value3 = false
if str_false then
bool_value3 = true
end
-- bool_value3 = true
print("bool_value1 = " .. tostring(bool_value1))
print("bool_value2 = " .. tostring(bool_value2))
print("bool_value3 = " .. tostring(bool_value3))