Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions RobloxPlugin/Minify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@ function PrintTable(tb, atIndent)
local useNewlines = (CountTable(tb) > 1)
local baseIndent = string.rep(' ', atIndent+1)
local out = "{"..(useNewlines and '\n' or '')
local tmpType
for k, v in pairs(tb) do
if type(v) ~= 'function' then
local tmpType = type(v)
if tmpType ~= 'function' then
out = out..(useNewlines and baseIndent or '')
if type(k) == 'number' then
if tmpType == 'number' then
--nothing to do
elseif type(k) == 'string' and k:match("^[A-Za-z_][A-Za-z0-9_]*$") then
out = out..k.." = "
elseif type(k) == 'string' then
out = out.."[\""..k.."\"] = "
elseif tmpType == 'string' then
if k:match("^[A-Za-z_][A-Za-z0-9_]*$") then
out = out..k.." = "
else
out = out.."["..string.format("%q", k).."] = "
end
else
out = out.."["..tostring(k).."] = "
end
if type(v) == 'string' then
out = out.."\""..v.."\""
elseif type(v) == 'number' then
if tmpType == 'string' then
out = out..string.format("%q", v)
elseif tmpType == 'number' then
out = out..v
elseif type(v) == 'table' then
elseif tmpType == 'table' then
out = out..PrintTable(v, atIndent+(useNewlines and 1 or 0))
else
out = out..tostring(v)
Expand Down Expand Up @@ -1567,4 +1571,4 @@ _G.Minify = function(src)
local st, ast = ParseLua(src)
if not st then return false, ast end
return true, Format_Mini(ast)
end
end