• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 20th, 2019 86 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 - 1
7. end
8. X.len = len
9.
10. function tostr(x)
11.   if type(x) == "boolean" then
12.     if x then x = "true" else x = "false" end
13.   elseif type(x) == "number" or type(x) == "string" then
14.     x = tostring(x)
15.   else
16.     x = type(x)
17.   end
18.   return x
19. end
20. X.tostr = tostr
21.
22. function keysvals(t)
23.   local i = 1
24.   local ks = {}
25.   local vs = {}
26.   for k,v in pairs(t) do
27.     ks[i] = k; vs[i] = v; i = i + 1
28.   end
29.   return ks,vs
30. end
31. X.keysvals = keysvals
32.
33. function tprint(t)
34.   local i = 1
35.   local ks
36.   local vs
37.   local v
38.   ks,vs = keysvals(t)
39.   while ks[i] ~= nil do
40.     v = tostr(vs[i])
41.     print(ks[i].." ; "..v)
42.     i = i + 1
43.   end
44. end
45. X.tprint = tprint
46.
47. function aprint(a)
48.   local i, j, s
49.   i = 1
50.   while a[i] ~= nil do
51.     s = tostr(a[i][1])
52.     j = 2
53.     while a[i][j] ~= nil do
54.       s = s.." ; "..tostr(a[i][j])
55.       j = j + 1
56.     end
57.     print(s)
58.     i = i + 1
59.   end
60. end
61. X.aprint = aprint
62.
63. 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.

Top