Run it
Copy the script and paste it into your executor.
-- ReSub Compression
local Map = {}
-- Important Numbers
local CurrentIndex = 0
-- Main Code
local function Compress(Content)
local Output = {}
Variables = {}
ContentLength = #Content
Prefix = ;
(Text)
_, Char , {, , , , , , , , , , , , }
Text = .(Text, .. Char, .. Char)
Text;
(Text)
.(Text, , )
(longestSubstring)
count =
UpdatedContent = Content
_ .(UpdatedContent, longestSubstring)
count = count +
count >
UpdatedContent = .(UpdatedContent, longestSubstring, .. CurrentIndex)
.(Variables, {CurrentIndex, (longestSubstring)})
CurrentIndex = CurrentIndex +
UpdatedContent
length = ContentLength, , -
start = , ContentLength - length +
substring = .(Content, start, start + length - )
LegalSubstring = (substring);
count =
_ .(Content, LegalSubstring)
count = count +
count > #substring > (CurrentIndex + )
Content = (LegalSubstring)
.(Variables, (a, b)
a[] < b[]
)
_, Info , Variables
Prefix ..= .. (Info[]) .. .. Info[] ..
.. Prefix .. .. Content;
(Content)
Variables = {};
LastSub = ;
ContentV2 = Content;
i = , #Content
Part = .(Content, i, i)
Part ==
v1, v2 = .(LastSub, )
v1 v2
.(Variables, {v1, v2})
LastSub = ;
LastSub = LastSub .. Part;
_, Info , Variables
ContentV2 = .(ContentV2, , (Index)
_, Info2 , Variables
Info2[] == Index
Info2[]
)
ContentV2 = .(ContentV2, , (a, b)
A = .(a, , )
B = .(b, , )
A = .(A, )[]
C = .(A, )
C[] == C[]
;
)
ContentV2 = .(ContentV2, , )
ContentV2;
{
Compress = Compress,
Decompress = Decompress
};ReSub Algorithm is a project I've worked on for fun, While I was bored I decided to make something that is slightly helpful for some people. FAQ: What is ReSub? ReSub is a text compression algorithm that finds duplicate substrings used in a file and replaces those with symbols (b%d) Why use ReSub? No real reason to use it other than reducing file sizes by up to 20%. ReSub is gonna be maintained by ME & ONLY ME. Currently in beta, please report any bugs to my dms (libary.hello or ballsman3761 on discord) Known bugs: Substrings that have ; might break the script, Substrings with b%d=... might also break the script.