Advertisement
pitrioptixiop

Roblox scripts function thing: table printing like in SQL

Oct 10th, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1.  
  2. --Try putting this at the beginning of the script!
  3.  
  4. function list(lv,ln,lm,lt)
  5.     a = {}
  6.     for i=1, #lv do
  7.         if #a == 0 then
  8.         table.insert(a,1,{i,lv[i]})
  9.         else
  10.         table.insert(a,#a,{i,lv[i]})
  11.         end
  12.     end
  13.     if lm ~= nil then
  14.         if lm == "print" then
  15.             t = "--"..lt.."--:\n--"..ln.."--"
  16.             for i=1, #a do
  17.                 t = t.."\n| "..a[i][1].."   :   "..a[i][2]
  18.             end
  19.             t = t.."\n--------------------------"
  20.             print(t)
  21.         elseif lm == "warn" then
  22.             t = "--"..lt.."--:\n--"..ln.."--"
  23.             for i=1, #a do
  24.                 t = t.."\n| "..a[i][1].."   :   "..a[i][2]
  25.             end
  26.             t = t.."\n--------------------------"
  27.             warn(t)
  28.         elseif lm == "error" then
  29.             t = "--"..lt.."--:\n--"..ln.."--"
  30.             for i=1, #a do
  31.                 t = t.."\n| "..a[i][1].."   :   "..a[i][2]
  32.             end
  33.             t = t.."\n--------------------------"
  34.             error(t)
  35.         elseif lm ~= nil and lm ~= "print" and lm ~= "warn" and lm ~= "error" then
  36.             warn("Error in function list() -- mode '"..lm.."' isn't nil and isn't valid; use print/warn/error")
  37.         end
  38.         end
  39.         return a
  40.         end
  41.        
  42.         --Try running this in your script:
  43.         --variables:
  44.         --lv = any table
  45.         --ln = name of the thing to print
  46.         --lm = mode [print or warn or error; otherwise nil]
  47.         --lt = a string if mode isn't nil and print or warn or error
  48.         list({"a","b","c","lol"},"Testing 123","warn","here's something testy")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement