
338.1k Views
201 Executions
Does it work?
Early reports100% say it works · 1 report in the last 2 weeks
Also noticed:
Description
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.
-- ReSub Compression
local Map = {}
-- Important Numbers
local CurrentIndex = 0
-- Main Code
local function Compress(Content)
local Output = {}
local Variables = {}
local ContentLength = #Content
local Prefix = [[]];
local function Legalize(Text)
for _, Char in next, {"$", "%", "^", "&", "*", "(", ")", "-", "+", "?", ".", "[", "]"} do
Text = string.gsub(Text, "%" .. Char, "%%" .. Char)
end
return Text;
end
local function Normalize(Text)
return string.gsub(Text, "%%", "")
end
local function Replace(longestSubstring)
local count = 0
local UpdatedContent = Content
for _ in string.gmatch(UpdatedContent, longestSubstring) do
count = count + 1
end
if count > 1 then
UpdatedContent = string.gsub(UpdatedContent, longestSubstring, "b" .. CurrentIndex)
table.insert(Variables, {CurrentIndex, Normalize(longestSubstring)})
CurrentIndex = CurrentIndex + 1
end
ReSub Compression








@Kagaforgotpassword ReSub is a compression algorithm (obvious). It looks for repeated substrings (substrings are smaller strings that came from a large string) in your code, and compresses the text by replacing duplicate substrings with b%d, where %d is an increasing index.
@MaybeJohnnyLol Okay I will try to understand it
What the hell I don't understand at all because I'm not scripter ðŠĶ
Good
Cool script