Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dumper = {};
- function dumper:GetTabChar(count)
- local c = ''
- for i = 1, count do
- c = c .. '\t';
- end
- return c;
- end
- function dumper:CheckGlobal(pGlobal, tab, tString, count)
- if (tab == nil) then tab = _G; end;
- if (count == nil) then count = 0; end;
- if (tString == nil) then tString = ""; end;
- if (count ~= 2) then
- count = count + 1;
- local cache = {};
- for name, val in pairs(tab) do
- if (type(val) == "table") then
- cache[name] = val;
- end
- if (val == pGlobal) then
- tString = tString .. name;
- return tString;
- end
- end
- for name, val in pairs(cache) do
- local r = dumper:CheckGlobal(pGlobal, val, tString, count);
- if (r ~= false) then
- tString = tString .. name .. "." .. r;
- return tString
- end
- end
- end
- --[[
- function innerCheck(t)
- for name,val in pairs(t) do
- if (val == pGlobal) then
- return name;
- end
- if (type(val) == "table") then
- if (val ~= tab) then
- return innerCheck(val);
- end
- end
- end
- end
- --]]
- return false;
- end
- function dumper:conv_to_str(int)
- local hexwheel = "0123456789ABCDEF"
- local hexstr = ""
- int = int + 1
- while int > 0 do
- local mod = math.fmod(int, 16)
- hexstr = string.sub(hexwheel, mod+1, mod+1) .. hexstr
- int = math.floor(int/16)
- end
- if hexstr == "" then return "0x0" end
- return "0x" .. hexstr
- end
- function dumper:SerializeName(name)
- if (type(name) == "string") then
- return "[\"" .. name .. "\"]";
- elseif (type(name) == "number") then
- return "[" .. name .. "]";
- end
- end
- function dumper:SerializeValue(name, value, index)
- if (type(value) == "string") then
- if (index == name) then
- return "\"" .. value .. "\"";
- else
- return dumper:SerializeName(name) .. " = " .. "\"" .. value .. "\"";
- end
- elseif (type(value) == "number") then
- if value > 10000 then value = dumper:conv_to_str(value) end
- if (index == name) then
- return tostring(value);
- else
- return dumper:SerializeName(name) .. " = " .. tostring(value);
- end
- elseif (type(value) == "boolean") then
- if (index == name) then
- return tostring(value);
- else
- return dumper:SerializeName(name) .. " = " .. tostring(value);
- end
- elseif (type(value) == "table") then
- if (index == name) then
- return tostring(value);
- else
- return dumper:SerializeName(name) .. " = " .. tostring(value);
- end
- elseif (type(value) == "userdata") then
- if (index == name) then
- if (not dumper:CheckGlobal(value)) then
- return "\"" .. tostring(value) .. "\"";
- else
- return dumper:CheckGlobal(value);
- end
- else
- if (not dumper:CheckGlobal(value)) then
- return dumper:SerializeName(name) .. " = " .. "\"" .. tostring(value) .. "\""
- else
- return dumper:SerializeName(name) .. " = " .. dumper:CheckGlobal(value);
- end
- end
- elseif (type(value) == "function") then
- if (index == name) then
- if (not dumper:CheckGlobal(value)) then
- return "\"" .. tostring(value) .. "\"";
- else
- return dumper:CheckGlobal(value);
- end
- else
- if (not dumper:CheckGlobal(value)) then
- return dumper:SerializeName(name) .. " = " .. "\"" .. tostring(value) .. "\"";
- else
- return dumper:SerializeName(name) .. " = " .. dumper:CheckGlobal(value);
- end
- end
- end
- print('unknown_value type: ' .. type(value))
- return "unknown_value";
- end
- function dumper:DumpTable(gTab, mode, recursive)
- if (gTab == nil) then gTab = {}; end;
- if (recursive == nil) then recursive = true; end;
- local deserialized = "";
- local gTabScanned = false;
- local tIndex = -1;
- if (mode == nil) then mode = 0; end;
- local function innerDump(tab, key)
- if (key == nil) then key = ""; end;
- if (tIndex > 20) then
- return
- end
- tIndex = tIndex + 1;
- if (key == "lineinfo") then
- deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "[\"" .. key .. "\"] = { --[[ blacklisted key ]] }\n";
- tIndex = tIndex - 1;
- return
- end
- if (key ~= "") then
- deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "[\"" .. key .. "\"] = {\n";
- else
- deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "{\n";
- end
- local currIndex = 0;
- if (tab == gTab) then
- if (gTabScanned) then
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. "{...}\n";
- else
- gTabScanned = true;
- end
- end
- for name,val in pairs(tab) do
- currIndex = currIndex + 1;
- if (type(val) == "table") then
- if (recursive == true) then
- if (val ~= gTab) then
- innerDump(val, name);
- else
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. "{...}\n";
- end
- else
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. "\n";
- end
- else
- if (currIndex == #tab) then
- if (mode == 1) then
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. "\t\t-- " .. tostring(val) .. "\n";
- else
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. "\n";
- end
- else
- if (mode == 1) then
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. ",\t\t-- " .. tostring(val) .. "\n";
- else
- deserialized = deserialized .. dumper:GetTabChar(tIndex+1) .. dumper:SerializeValue(name, val, currIndex) .. ",\n";
- end
- end
- end
- end
- deserialized = deserialized .. dumper:GetTabChar(tIndex) .. "}\n"
- tIndex = tIndex - 1;
- end
- innerDump(gTab);
- return deserialized;
- end
- function dt(t)
- return dumper:DumpTable(t)
- end
- local iv = {}
- for i,v in pairs(workspace:GetDescendants()) do
- if v:IsA("BasePart") then
- local position, bool = workspace.Camera:WorldToScreenPoint(v.Position)
- if bool then
- table.insert(iv, v) -- or put something else that you want to do with the block
- end
- end
- end
- local str = dt(iv)
- local build = ""
- for i = 1, #str do
- local c = str:sub(i,i)
- local b = c:byte()
- local r = string.format("%X", b)
- build = build .. r
- end
- print(build)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement