summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lualibs-boolean.lua16
1 files changed, 7 insertions, 9 deletions
diff --git a/lualibs-boolean.lua b/lualibs-boolean.lua
index 2b94de7..f087f1a 100644
--- a/lualibs-boolean.lua
+++ b/lualibs-boolean.lua
@@ -15,7 +15,7 @@ function boolean.tonumber(b)
if b then return 1 else return 0 end -- test and return or return
end
-function toboolean(str,tolerant)
+function toboolean(str,tolerant) -- global
if str == nil then
return false
elseif str == false then
@@ -40,18 +40,16 @@ end
string.toboolean = toboolean
function string.booleanstring(str)
- if str == nil then
- return false
- elseif str == false then
+ if str == "0" then
return false
- elseif str == true then
- return true
- elseif str == "true" then
+ elseif str == "1" then
return true
- elseif str == "false" then
+ elseif str == "" then
return false
- elseif str == 0 then
+ elseif str == "false" then
return false
+ elseif str == "true" then
+ return true
elseif (tonumber(str) or 0) > 0 then
return true
else