SHARE
TWEET

CG303 Table Show Deep V1.000

Crashguard303 Apr 24th, 2013 9 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. AKA: Table Show Deep V1.000
  3. essence of show table completely:
  4. https://foldit_research.titanpad.com/65
  5. --]]
  6. function list_show_deep(list,text)
  7. -- full key and value as string - advanced
  8. -- indexing: pairs
  9.  if text==nil then
  10.     text=tostring(list)
  11.  end -- if text
  12.  local k,v
  13.  for k,v in pairs(list) do
  14.      local ktext
  15.      if type(k)=="number" then
  16.         ktext= text..'['..tostring(k)..']'
  17.      else
  18.         ktext= text..'.'..tostring(k)
  19.      end -- if type(k)
  20.      if type(v)=="table" then
  21.         list_show_deep(v,ktext)
  22.      else
  23.         local vtext
  24.         if (type(v)=="number") or (type(v)=="boolean") then
  25.            vtext= tostring(v)
  26.         else
  27.            vtext= '\"'..tostring(v)..'\"'
  28.         end -- if type(v)
  29.         print(ktext..'='..vtext)
  30.      end -- if type(v)
  31.  end -- for k
  32. end -- function list_show_deep
  33. test={
  34.       title="root table";
  35.       "1";
  36.       {
  37.        title="first subtable";
  38.        "2.1";
  39.        "2.2"
  40.       };
  41.       {
  42.        title="second subtable";
  43.        {
  44.         title="first subtable of second subtable";
  45.         "3.1.1";
  46.         "3.1.2"
  47.        };
  48.        {
  49.         title="second subtable of second subtable";
  50.         "3.2.1";
  51.         "3.2.2"
  52.        };
  53.       }
  54.      }
  55. list_show_deep(test,"test")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top