aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-26 16:56:08 +1000
committerDavid Walter Seikel2014-03-26 16:56:08 +1000
commitb0636daa0db080b584a11d2a26ac6fcd01125403 (patch)
tree16fcfa40535e2b251d5cd774badd424cc34af57d /ClientHamr
parentRe arrange so that the Thing definitions are all together. (diff)
downloadSledjHamr-b0636daa0db080b584a11d2a26ac6fcd01125403.zip
SledjHamr-b0636daa0db080b584a11d2a26ac6fcd01125403.tar.gz
SledjHamr-b0636daa0db080b584a11d2a26ac6fcd01125403.tar.bz2
SledjHamr-b0636daa0db080b584a11d2a26ac6fcd01125403.tar.xz
Add my standard isBoolean().
Diffstat (limited to 'ClientHamr')
-rw-r--r--ClientHamr/GuiLua/skang.lua24
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
124local _M = moduleBegin('skang', 'David Seikel', '2014', '0.0', '2014-03-19 19:01:00') 124local _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'
129local isTrue = 't1aopswy'
130-- false 0 no nack nope zero negative nah 'no way' 'get real' 'uh uh' 'fuck off' 'bugger off'
131local isFalse = 'f0bgnuz'
132isBoolean = 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
149end
150
127 151
128--[[ Thing package 152--[[ Thing package
129 153