Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- roblox_typeof = typeof or type;
- roblox_typeof_new = {
- BrickColor = true,
- Color3 = true,
- Vector2 = true,
- Vector3 = true,
- CFrame = true,
- Region3 = true,
- UDim2 = true
- };
- push_and_clone = function (tbl, val)
- local clone = {};
- for k, v in next, tbl do
- clone[k] = v;
- end;
- clone [#clone + 1] = val;
- return clone;
- end;
- table_to_string = function (tbl, index, path)
- local index = index or 1;
- local path = path or {};
- local output = (getmetatable (tbl) == nil and '' or '[METATABLE]') .. '{\n';
- for i, v in next, path do
- if (v == tbl and i ~= #path) then
- return '[Circular Reference]';
- end;
- end;
- for k, v in next, tbl do
- output = output .. string.rep ('\t', index) .. '[';
- if (roblox_typeof (k) == 'table') then
- output = output .. table_to_string (k, 1, push_and_clone (path, k));
- elseif (roblox_typeof (k) == 'string') then
- output = output .. '"' .. k .. '"';
- elseif (roblox_typeof_new [roblox_typeof (k)]) then
- output = output .. roblox_typeof (k) .. '.new (' .. tostring(v) .. ')'
- else
- output = output .. tostring (k);
- end;
- output = output .. '] = ';
- if (roblox_typeof (v) == 'table') then
- output = output .. table_to_string (v, index + 1, push_and_clone (path, v));
- elseif (roblox_typeof (v) == 'string') then
- output = output .. '"' .. v .. '"';
- elseif (roblox_typeof_new [roblox_typeof (v)]) then
- output = output .. roblox_typeof (v) .. '.new (' .. tostring(v) .. ')'
- else
- output = output .. tostring (v);
- end;
- output = output .. '\n';
- end;
- return output .. string.rep ('\t', math.max (index - 1, 0)) .. '};';
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement