diff options
author | David Walter Seikel | 2012-02-05 20:57:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-05 20:57:23 +1000 |
commit | 7b4e28a573caacec9f517b50b5a67d946403befd (patch) | |
tree | 514e347a76fc104793a46a93818f29a735ad4c70 /LuaSL | |
parent | Complete the separation of the guts of luaproc message sending from the Lua w... (diff) | |
download | SledjHamr-7b4e28a573caacec9f517b50b5a67d946403befd.zip SledjHamr-7b4e28a573caacec9f517b50b5a67d946403befd.tar.gz SledjHamr-7b4e28a573caacec9f517b50b5a67d946403befd.tar.bz2 SledjHamr-7b4e28a573caacec9f517b50b5a67d946403befd.tar.xz |
Add table printing functions for debugging.
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LSL.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua index 8774121..82f7205 100644 --- a/LuaSL/src/LSL.lua +++ b/LuaSL/src/LSL.lua | |||
@@ -30,6 +30,32 @@ upvalue--either way is a bit more efficient and less error prone. | |||
30 | 30 | ||
31 | local LSL = {}; | 31 | local LSL = {}; |
32 | 32 | ||
33 | |||
34 | -- Debugging aids | ||
35 | |||
36 | -- Functions to print tables. | ||
37 | local print_table, print_table_start; | ||
38 | |||
39 | function print_table_start(table, space, name) | ||
40 | print(space .. name .. ": "); | ||
41 | print(space .. "{"); | ||
42 | print_table(table, space .. " "); | ||
43 | print(space .. "}"); | ||
44 | end | ||
45 | |||
46 | function print_table(table, space) | ||
47 | for k, v in pairs(table) do | ||
48 | if type(v) == "table" then | ||
49 | print_table_start(v, space, k); | ||
50 | elseif type(v) == "string" then | ||
51 | print(space .. k .. ': "' .. v .. '";') | ||
52 | else | ||
53 | print(space .. k .. ": " .. v .. ";") | ||
54 | end | ||
55 | end | ||
56 | end | ||
57 | |||
58 | |||
33 | -- LSL constants. | 59 | -- LSL constants. |
34 | 60 | ||
35 | LSL.PI = 3.14159265358979323846264338327950; | 61 | LSL.PI = 3.14159265358979323846264338327950; |