tobool should handle bools correctly.
This commit is contained in:
@@ -304,8 +304,9 @@ function getenv(name) return envTable[name] end
|
|||||||
-- tobool(v)
|
-- tobool(v)
|
||||||
-- Converts v to a boolean.
|
-- Converts v to a boolean.
|
||||||
function tobool(v)
|
function tobool(v)
|
||||||
if getmetatable(v) and (getmetatable(v))["__tobool"] and type((getmetatable(v))["__tobool"])=="function" then
|
local meta= getmetatable(v)
|
||||||
return (getmetatable(v))["__tobool"](v)
|
if meta and type(meta.__tobool) == "function" then
|
||||||
|
return meta.__tobool(v)
|
||||||
elseif type(v) == "string" then
|
elseif type(v) == "string" then
|
||||||
local cmp = string.lower(v)
|
local cmp = string.lower(v)
|
||||||
if cmp == "true" or cmp == "t" then
|
if cmp == "true" or cmp == "t" then
|
||||||
@@ -319,7 +320,10 @@ function tobool(v)
|
|||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
elseif type(v) == "boolean" then
|
||||||
|
return v
|
||||||
end
|
end
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- GetPlayerOrMachineProfile(pn)
|
-- GetPlayerOrMachineProfile(pn)
|
||||||
|
|||||||
Reference in New Issue
Block a user