From 2c6776c4804095774934b97edacb818fad180885 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Sun, 4 Jan 2015 22:27:34 -0700 Subject: [PATCH] tobool should handle bools correctly. --- Themes/_fallback/Scripts/02 Utilities.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Themes/_fallback/Scripts/02 Utilities.lua b/Themes/_fallback/Scripts/02 Utilities.lua index 53a3acf534..8b53d55055 100644 --- a/Themes/_fallback/Scripts/02 Utilities.lua +++ b/Themes/_fallback/Scripts/02 Utilities.lua @@ -304,8 +304,9 @@ function getenv(name) return envTable[name] end -- tobool(v) -- Converts v to a boolean. function tobool(v) - if getmetatable(v) and (getmetatable(v))["__tobool"] and type((getmetatable(v))["__tobool"])=="function" then - return (getmetatable(v))["__tobool"](v) + local meta= getmetatable(v) + if meta and type(meta.__tobool) == "function" then + return meta.__tobool(v) elseif type(v) == "string" then local cmp = string.lower(v) if cmp == "true" or cmp == "t" then @@ -319,7 +320,10 @@ function tobool(v) else return true end + elseif type(v) == "boolean" then + return v end + return nil end -- GetPlayerOrMachineProfile(pn)