SHARE
TWEET

qlib.lua

a guest Nov 19th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local X = {}
  2.  
  3. function len(t)
  4.   local i = 1
  5.   while t[i] ~= nil do i = i + 1 end
  6.   return i
  7. end
  8. X.len = len
  9.  
  10. function keysvals(t)
  11.   local i = 1
  12.   local ks = {}
  13.   local vs = {}
  14.   for k,v in pairs(t) do
  15.     ks[i] = k; vs[i] = v; i = i + 1
  16.   end
  17.   return ks,vs
  18. end
  19. X.keysvals = keysvals
  20.  
  21. function tprint(t)
  22.   local i = 1
  23.   local ks
  24.   local vs
  25.   local v
  26.   ks,vs = keysvals(t)
  27.   while ks[i] ~= nil do
  28.     v = vs[i]
  29.     if type(v) == "boolean" then
  30.       v = if v then "true" else "false" end
  31.     elseif not (type(v) == "number" or type(v) == "string") then
  32.       v = type(v)
  33.     end
  34.     print(ks[i].." : "..v)
  35.   end
  36. end
  37. X.tprint = tprint
  38.  
  39. return X
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