diff options
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index 418cd10..d8f0343 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -124,6 +124,30 @@ end | |||
124 | local _M = moduleBegin('skang', 'David Seikel', '2014', '0.0', '2014-03-19 19:01:00') | 124 | local _M = moduleBegin('skang', 'David Seikel', '2014', '0.0', '2014-03-19 19:01:00') |
125 | 125 | ||
126 | 126 | ||
127 | -- My clever boolean check, this is the third language I've written this in. B-) | ||
128 | -- true 1 yes ack ok one positive absolutely affirmative 'ah ha' 'shit yeah' 'why not' | ||
129 | local isTrue = 't1aopswy' | ||
130 | -- false 0 no nack nope zero negative nah 'no way' 'get real' 'uh uh' 'fuck off' 'bugger off' | ||
131 | local isFalse = 'f0bgnuz' | ||
132 | isBoolean = function (aBoolean) | ||
133 | local result = false | ||
134 | |||
135 | if type(aBoolean) ~= 'nil' then | ||
136 | -- The default case, presence of a value means it's true. | ||
137 | result = true | ||
138 | if type(aBoolean) == 'boolean' then result = aBoolean | ||
139 | elseif type(aBoolean) == 'function' then result = aBoolean() | ||
140 | elseif type(aBoolean) == 'number' then result = (aBoolean ~= 0) | ||
141 | elseif type(aBoolean) == 'string' then | ||
142 | if '' == aBoolean then result = false else | ||
143 | if 1 == string.find(string.lower(aBoolean), '^[' .. isTrue .. ']') then result = true end | ||
144 | if 1 == string.find(string.lower(aBoolean), '^[' .. isFalse .. ']') then result = false end | ||
145 | end | ||
146 | end | ||
147 | end | ||
148 | return result | ||
149 | end | ||
150 | |||
127 | 151 | ||
128 | --[[ Thing package | 152 | --[[ Thing package |
129 | 153 | ||