i would like how to compress programs, npaintpro images and random files so i can make 1 file for all and make that file 3 or 4 times smaller than the original files, any ideas?
Compression
Started by FuuuAInfiniteLoop(F.A.I.L), Feb 09 2013 03:43 PM
5 replies to this topic
#1
Posted 09 February 2013 - 03:43 PM
#2
Posted 09 February 2013 - 04:04 PM
Perhaps you could save the text of all of the files as multiline strings in one program?
And then pairs() through them all and write them accordingly.
Though there's probably a better, and more automatic way to do this. I believe some people around here have made some compression programs.
local programs = {
program1 = [[
print 'Hello World!'
]];
program2 = [[
print 'This is another program!'
]];
}
And then pairs() through them all and write them accordingly.
for programName, content in pairs(programs) do local file = fs.open(programName, 'w') file.write(content) file.close() end
Though there's probably a better, and more automatic way to do this. I believe some people around here have made some compression programs.
#3
Posted 09 February 2013 - 04:14 PM
for saving all files in a one file the code is this:
file.1lol
file2.pr
file5.nfa
etc
and the output:
{["file.1lol"] = content, etc
and the result will only have one line(if you dont count the part for reading it so it can be runned), but i want to compress that so it gets like 4 times less that the original output, its possible?
file = fs.open("files", "r")
b = {}
while true do
d = file.readLine()
c = fs.open(d, "r")
if not d then break end
a = c.readAll()
b[d] = a
end
file.close()
file = fs.open("output", "w")
file.write(textutils.serialize(B)/>
file.close()
the file is like:file.1lol
file2.pr
file5.nfa
etc
and the output:
{["file.1lol"] = content, etc
and the result will only have one line(if you dont count the part for reading it so it can be runned), but i want to compress that so it gets like 4 times less that the original output, its possible?
#4
Posted 09 February 2013 - 04:43 PM
The only way I know of would be to run through the string, and shorten any frequently used keywords, like "function" or "local" to something like "@f" or "@l", a unique identifier that isn't available in regular lua syntax so nothing is mixed up. Then, on rewriting the programs, replace the shortenings with their original keywords.
I've only scraped the surface of actual compression, however, so I'm positive there's a better way to do that.
I've only scraped the surface of actual compression, however, so I'm positive there's a better way to do that.
#5
Posted 09 February 2013 - 05:21 PM
I have crreated a program that compress files check it out
#6
Posted 09 February 2013 - 05:49 PM
Locked as requested.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users


This topic is locked








