aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/skang.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-29 23:39:50 +1000
committerDavid Walter Seikel2014-03-29 23:39:50 +1000
commitb3bed827dcb3e1b5db02172d906ff61bf6545bf9 (patch)
tree84c7eac71c8d4cbab483c249e5e9b074b0a5ce15 /ClientHamr/GuiLua/skang.lua
parentTwo alternate ideas for how to do Things. (diff)
downloadSledjHamr-b3bed827dcb3e1b5db02172d906ff61bf6545bf9.zip
SledjHamr-b3bed827dcb3e1b5db02172d906ff61bf6545bf9.tar.gz
SledjHamr-b3bed827dcb3e1b5db02172d906ff61bf6545bf9.tar.bz2
SledjHamr-b3bed827dcb3e1b5db02172d906ff61bf6545bf9.tar.xz
Add my usual table printer.
Diffstat (limited to '')
-rw-r--r--ClientHamr/GuiLua/skang.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index 3848093..3baad4f 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -162,6 +162,37 @@ local _M = moduleBegin('skang', 'David Seikel', 'Copyright 2014 David Seikel', '
162print('Skang is running under Lua version ' .. _VERSION) 162print('Skang is running under Lua version ' .. _VERSION)
163 163
164 164
165
166function printTableStart(table, space, name)
167 print(space .. name .. ": ")
168 print(space .. "{")
169 printTable(table, space .. " ")
170 print(space .. "}")
171end
172
173function printTable(table, space)
174 for k, v in pairs(table) do
175 if type(v) == "table" then
176 printTableStart(v, space, k)
177 elseif type(v) == "string" then
178 print(space .. k .. ': "' .. v .. '";')
179 elseif type(v) == "function" then
180 print(space .. "function " .. k .. "();")
181 elseif type(v) == "userdata" then
182 print(space .. "userdata " .. k .. ";")
183 elseif type(v) == "boolean" then
184 if (v) then
185 print(space .. "boolean " .. k .. " TRUE ;")
186 else
187 print(space .. "boolean " .. k .. " FALSE ;")
188 end
189 else
190 print(space .. k .. ": " .. v .. ";")
191 end
192 end
193end
194
195
165csv2table = function (csv) 196csv2table = function (csv)
166 local result = {} 197 local result = {}
167 local i = 1 198 local i = 1