aboutsummaryrefslogtreecommitdiff
path: root/src/syslua/lx/lxinit.lua
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-04-19 12:13:30 +0200
committerAlex Auvolat <alex@adnab.me>2017-04-19 12:13:30 +0200
commitd4a89538d381bb62b4c7c864b09d3d8274cf0bdb (patch)
treedb9f4e0066eddd7661eaf92375e84d584c64d987 /src/syslua/lx/lxinit.lua
parent8e88e765ee17296a85c5ae372471ed248ce321db (diff)
downloadkogata-d4a89538d381bb62b4c7c864b09d3d8274cf0bdb.tar.gz
kogata-d4a89538d381bb62b4c7c864b09d3d8274cf0bdb.zip
First code for lx (Lua eXtended)
Diffstat (limited to 'src/syslua/lx/lxinit.lua')
-rw-r--r--src/syslua/lx/lxinit.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/syslua/lx/lxinit.lua b/src/syslua/lx/lxinit.lua
new file mode 100644
index 0000000..6b23aa8
--- /dev/null
+++ b/src/syslua/lx/lxinit.lua
@@ -0,0 +1,22 @@
+print "Lua eXtended 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