This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
etn's profile picture

Compress code to valid lua

Started by etn, 09 July 2016 - 04:45 AM
etn #1
Posted 09 July 2016 - 06:45 AM
Is there a program for shrinking lua code to smaller code in computercraft?

for example this-


os.loadApi("myApi")
local var1=myApi.func1()
local var2=myApi.func2(var1)
local var3
local function do1()
	var3=myApi.func3(var2,var3)
	print(table.unpack(myApi.func6(var3),myApi.const5))
end
local function do2(arg1)
	return myApi.func4(var3)[myApi.func5(var1)]
end
for index=1,50 do
	do1()
	print(do2(myApi.func2(do2(var3))))
end
return table.pack(myApi.func7(var1,var2,var3))

should become something like this-


os.loadApi("myApi")local a,b,c=myApi,table,print
local d,e,f=a.func1(),a.func2
local g,h=e(d),function()return a.func4(f)[a.func5(d)]end
for i=1,50 do
f=a.func3(g,f)c(b.unpack(a.func6(f),a.const5))c(h(e(h(f))))
end
return b.pack(a.func7(d,g,f))
Bomb Bloke #2
Posted 09 July 2016 - 09:15 AM
The tool you're talking about is called a "minifier". SquidDev's Howl has an example.
etn #3
Posted 10 July 2016 - 02:24 AM
Thank you :)/>