Universal Script 📌
338.1k Views
201 Executions

Script Verified ReSub Compression

Universal Script 📌
vxsty
vxsty
Verified Badge
Verified User
Hall of Fame10M views
2 years ago
Get an executor
Please login to perform these actions:

Does it work?

Early reports

100% 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.

View Raw
-- 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



Comments

5
Log in to join the conversation. Login
WhatsHisIdentifier's profile picture
WhatsHisIdentifier2 years ago(edited)

@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.

3
Kagasad's profile picture
Kagasad2 years ago(edited)

@MaybeJohnnyLol Okay I will try to understand it

2
Kagasad's profile picture
Kagasad2 years ago(edited)

What the hell I don't understand at all because I'm not scripter ðŸŠĶ

2
galaxyfounded's profile picture
galaxyfounded2 years ago(edited)

Good

2
aybat_ataybek's profile picture
aybat_ataybek1 week ago

Cool script

1

Tags

More universal scripts

See all
Script hub
51
2
2 days ago
Key System
Paid
Script hub
3.0M
14.6M
3 years ago

Script hub

Hall of Fame #1

KeylessVerified script badgeYARHM - MM2, FTF, Forsaken, etc.

Script hub
151
6
2 days ago
Key System
Universal Script 📌
4.7k
27.2k
4 months ago