diff options
author | Alex Auvolat <alex@adnab.me> | 2017-01-26 17:43:38 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-01-26 17:43:38 +0100 |
commit | 96da27494f89d75f8aec0c8894440c3f7482f54b (patch) | |
tree | a239f75acf6c2c11cfa54b895653f978980064cb /src/syslua/init.lua | |
parent | 809d660944cfb515e18bb7f1c1519392b4bccd53 (diff) | |
download | kogata-96da27494f89d75f8aec0c8894440c3f7482f54b.tar.gz kogata-96da27494f89d75f8aec0c8894440c3f7482f54b.zip |
More lua
Diffstat (limited to 'src/syslua/init.lua')
-rw-r--r-- | src/syslua/init.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/syslua/init.lua b/src/syslua/init.lua new file mode 100644 index 0000000..1ee7ee6 --- /dev/null +++ b/src/syslua/init.lua @@ -0,0 +1,22 @@ +print "Lua helpers for Kogata v1" + +do + local old_tostring = tostring + function tostring(x) + if type(x) == "table" then + if next(x) == nil then + return '{}' + end + local q = '{\n ' + for k, v in pairs(x) do + if q:len() > 4 then + q = q .. ',\n ' + end + q = q .. k .. ': ' .. tostring(v):gsub('\n', '\n ') + end + return q .. '\n}' + else + return old_tostring(x) + end + end +end |