diff Resources/Toolbox.lua @ 394:9784f19f7e1b lua-scripting

path relative to configuration path, list of lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 May 2013 11:02:15 +0200
parents 18fe778eeb95
children 941ea46e9e26
line wrap: on
line diff
--- a/Resources/Toolbox.lua	Tue Apr 30 15:41:07 2013 +0200
+++ b/Resources/Toolbox.lua	Thu May 02 11:02:15 2013 +0200
@@ -1,17 +1,18 @@
---[[ rPrint(struct, [limit], [indent])   Recursively print arbitrary data. 
+--[[ printRecursive(struct, [limit], [indent])   Recursively print arbitrary data. 
 Set limit (default 100) to stanch infinite loops.
 Indents tables as [KEY] VALUE, nested tables as [KEY] [KEY]...[KEY] VALUE
 Set indent ("") to prefix each line:    Mytable [KEY] [KEY]...[KEY] VALUE
-https://gist.github.com/stuby/5445834#file-rprint-lua
+Source: https://gist.github.com/stuby/5445834#file-rprint-lua
 --]]
-function rPrint(s, l, i) -- recursive Print (structure, limit, indent)
+
+function printRecursive(s, l, i) -- recursive Print (structure, limit, indent)
    l = (l) or 100; i = i or "";	-- default item limit, indent string
    if (l<1) then print "ERROR: Item limit reached."; return l-1 end;
    local ts = type(s);
    if (ts ~= "table") then print (i,ts,s); return l-1 end
    print (i,ts);           -- print "table"
    for k,v in pairs(s) do  -- print "[KEY] VALUE"
-      l = rPrint(v, l, i.."\t["..tostring(k).."]");
+      l = printRecursive(v, l, i.."\t["..tostring(k).."]");
       if (l < 0) then break end
    end
    return l