Advertisement
XZTablets

Untitled

Aug 10th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.53 KB | None | 0 0
  1. local dumper = {};
  2.  
  3. function dumper:GetTabChar(count)
  4. local c = ''
  5. for i = 1, count do
  6. c = c .. '\t';
  7. end
  8. return c;
  9. end
  10.  
  11. function dumper:CheckGlobal(pGlobal, tab, tString, count)
  12. if (tab == nil) then tab = _G; end;
  13. if (count == nil) then count = 0; end;
  14. if (tString == nil) then tString = ""; end;
  15.  
  16. if (count ~= 2) then
  17. count = count + 1;
  18. local cache = {};
  19. for name, val in pairs(tab) do
  20. if (type(val) == "table") then
  21. cache[name] = val;
  22. end
  23. if (val == pGlobal) then
  24. tString = tString .. name;
  25. return tString;
  26. end
  27. end
  28.  
  29. for name, val in pairs(cache) do
  30. local r = dumper:CheckGlobal(pGlobal, val, tString, count);
  31. if (r ~= false) then
  32. tString = tString .. name .. "." .. r;
  33. return tString
  34. end
  35. end
  36. end
  37.  
  38. --[[
  39. function innerCheck(t)
  40. for name,val in pairs(t) do
  41. if (val == pGlobal) then
  42. return name;
  43. end
  44. if (type(val) == "table") then
  45. if (val ~= tab) then
  46. return innerCheck(val);
  47. end
  48. end
  49. end
  50. end
  51. --]]
  52.  
  53. return false;
  54. end
  55.  
  56. function dumper:conv_to_str(int)
  57. local hexwheel = "0123456789ABCDEF"
  58. local hexstr = ""
  59. int = int + 1
  60. while int > 0 do
  61. local mod = math.fmod(int, 16)
  62. hexstr = string.sub(hexwheel, mod+1, mod+1) .. hexstr
  63. int = math.floor(int/16)
  64. end
  65. if hexstr == "" then return "0x0" end
  66. return "0x" .. hexstr
  67. end
  68.  
  69. function dumper:SerializeName(name)
  70. if (type(name) == "string") then
  71. return "[\"" .. name .. "\"]";
  72. elseif (type(name) == "number") then
  73. return "[" .. name .. "]";
  74. end
  75. end
  76.  
  77. function dumper:SerializeValue(name, value, index)
  78. if (type(value) == "string") then
  79. if (index == name) then
  80. return "\"" .. value .. "\"";
  81. else
  82. return dumper:SerializeName(name) .. " = " .. "\"" .. value .. "\"";
  83. end
  84. elseif (type(value) == "number") then
  85. if value > 10000 then value = dumper:conv_to_str(value) end
  86. if (index == name) then
  87. return tostring(value);
  88. else
  89. return dumper:SerializeName(name) .. " = " .. tostring(value);
  90. end
  91. elseif (type(value) == "boolean") then
  92. if (index == name) then
  93. return tostring(value);
  94. else
  95. return dumper:SerializeName(name) .. " = " .. tostring(value);
  96. end
  97. elseif (type(value) == "table") then
  98. if (index == name) then
  99. return tostring(value);
  100. else
  101. return dumper:SerializeName(name) .. " = " .. tostring(value);
  102. end
  103. elseif (type(value) == "userdata") then
  104. if (index == name) then
  105. if (not dumper:CheckGlobal(value)) then
  106. return "\"" .. tostring(value) .. "\"";
  107. else
  108. return dumper:CheckGlobal(value);
  109. end
  110. else
  111. if (not dumper:CheckGlobal(value)) then
  112. return dumper:SerializeName(name) .. " = " .. "\"" .. tostring(value) .. "\""
  113. else
  114. return dumper:SerializeName(name) .. " = " .. dumper:CheckGlobal(value);
  115. end
  116. end
  117. elseif (type(value) == "function") then
  118. if (index == name) then
  119. if (not dumper:CheckGlobal(value)) then
  120. return "\"" .. tostring(value) .. "\"";
  121. else
  122. return dumper:CheckGlobal(value);
  123. end
  124. else
  125. if (not dumper:CheckGlobal(value)) then
  126. return dumper:SerializeName(name) .. " = " .. "\"" .. tostring(value) .. "\"";
  127. else
  128. return dumper:SerializeName(name) .. " = " .. dumper:CheckGlobal(value);
  129. end
  130. end
  131. end
  132.  
  133. print('unknown_value type: ' .. type(value))
  134. return "unknown_value";
  135. end
  136.  
  137. function dumper:DumpTable(gTab, mode, recursive)
  138. if (gTab == nil) then gTab = {}; end;
  139. if (recursive == nil) then recursive = true; end;
  140. local deserialized = "";
  141. local gTabScanned = false;
  142. local tIndex = -1;
  143.  
  144. if (mode == nil) then mode = 0; end;
  145.  
  146. local function innerDump(tab, key)
  147. if (key == nil) then key = ""; end;
  148. if (tIndex > 20) then
  149. return
  150. end
  151. tIndex = tIndex + 1;
  152. if (key == "lineinfo") then
  153. deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "[\"" .. key .. "\"] = { --[[ blacklisted key ]] }\n";
  154. tIndex = tIndex - 1;
  155. return
  156. end
  157. if (key ~= "") then
  158. deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "[\"" .. key .. "\"] = {\n";
  159. else
  160. deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "{\n";
  161. end
  162. local currIndex = 0;
  163. if (tab == gTab) then
  164. if (gTabScanned) then
  165. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. "{...}\n";
  166. else
  167. gTabScanned = true;
  168. end
  169. end
  170.  
  171. for name,val in pairs(tab) do
  172. currIndex = currIndex + 1;
  173. if (type(val) == "table") then
  174. if (recursive == true) then
  175. if (val ~= gTab) then
  176. innerDump(val, name);
  177. else
  178. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. "{...}\n";
  179. end
  180. else
  181. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. "\n";
  182. end
  183. else
  184. if (currIndex == #tab) then
  185. if (mode == 1) then
  186. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. "\t\t-- " .. tostring(val) .. "\n";
  187. else
  188. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. "\n";
  189. end
  190. else
  191. if (mode == 1) then
  192. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. ",\t\t-- " .. tostring(val) .. "\n";
  193. else
  194. deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. ",\n";
  195. end
  196. end
  197. end
  198. end
  199.  
  200. deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "}\n"
  201. tIndex = tIndex - 1;
  202. end
  203.  
  204. innerDump(gTab);
  205.  
  206. return deserialized;
  207. end
  208.  
  209. function dt(t)
  210. return dumper:DumpTable(t)
  211. end
  212.  
  213. local iv = {}
  214.  
  215. for i,v in pairs(workspace:GetDescendants()) do
  216. if v:IsA("BasePart") then
  217. local position, bool = workspace.Camera:WorldToScreenPoint(v.Position)
  218. if bool then
  219. table.insert(iv, v) -- or put something else that you want to do with the block
  220. end
  221. end
  222. end
  223.  
  224. local str = dt(iv)
  225.  
  226. local build = ""
  227.  
  228. for i = 1, #str do
  229. local c = str:sub(i,i)
  230. local b = c:byte()
  231. local r = string.format("%X", b)
  232. build = build .. r
  233. end
  234.  
  235. print(build)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement