SHARE
TWEET

littleSerial.lua

fatboychummy Feb 21st, 2020 (edited) 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function littleSerial(tbl, spc)
  2.   spc = spc or 2
  3.  
  4.   local str = "{\n"
  5.   local function app(a)
  6.     str = str .. a
  7.   end
  8.   local last = 0
  9.  
  10.   local repStr = string.rep(' ', spc)
  11.  
  12.   for i, v in ipairs(tbl) do
  13.     if i ~= i + 1 then
  14.       app(string.format("%s[ %d ] = ", repStr, i))
  15.       last = math.huge
  16.     else
  17.       last = last + 1
  18.     end
  19.     if type(v) = "table" then
  20.       app(littleSerial(v, spc + 2) .. ",\n")
  21.     else
  22.       app(repStr .. tostring(v) .. ",\n")
  23.     end
  24.   end
  25.   app("}")
  26.  
  27.   return str
  28. end
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