Anonymous Option is case-insensitive now + Can be customized

This commit is contained in:
phoriah
2024-11-13 01:30:11 +02:00
parent e4a02adfdc
commit 862bbec479

View File

@@ -1309,7 +1309,7 @@ local GLOBAL_ENV = getgenv and getgenv() or _G or shared
--- @field SafeMode boolean -- Kicks you before Saving, which prevents you from being detected in any game. ___Default:___ false
--- @field ShutdownWhenDone boolean -- Shuts the game down after saveinstance is finished. ___Default:___ false
--- @field AntiIdle boolean -- Prevents the 20-minute-Idle Kick. ___Default:___ true
--- @field Anonymous boolean -- * **RISKY:** Cleans the file of any info related to your account like: Name, UserId. This is useful for some games that might store that info in GUIs or other Instances. Might potentially mess up parts of strings that contain characters that match your Name or parts of numbers that match your UserId. ___Default:___ false
--- Anonymous {boolean|table{UserId = string, Name = string}} -- * **RISKY:** Cleans the file of any info related to your account like: Name, UserId. This is useful for some games that might store that info in GUIs or other Instances. Might potentially mess up parts of strings that contain characters that match your Name or parts of numbers that match your UserId. Can also be a table with UserId & Name keys. ___Default:___ false
--- @field ShowStatus boolean -- ___Default:___ true
--- @field Callback boolean -- If set, the serialized data will be sent to the callback function instead of to file. ___Default:___ nil
--- @field mode string -- Change this to invalid mode like "invalid" if you only want ExtraInstances. "optimized" mode is **NOT** supported with *@Object* option. ___Default:___ `"optimized"`
@@ -1694,6 +1694,10 @@ local function synsaveinstance(CustomOptions, CustomOptions2)
end
end
if FilePath then
FilePath = sanitizeFileName(FilePath)
end
if IsModel then
placename = (
FilePath
@@ -2772,9 +2776,47 @@ local function synsaveinstance(CustomOptions, CustomOptions2)
if OPTIONS.Anonymous then
local LocalPlayer = service.Players.LocalPlayer
if LocalPlayer then
local function gsubCaseInsensitive(input, search, replacement)
local inputLower = string.lower(input)
search = string.lower(search)
local lastFinish = 0
local subStrings = {}
local search_len = #search
local input_len = #input
while search_len <= input_len - lastFinish do
local init = lastFinish + 1
local start, finish = string.find(inputLower, search, init, true)
if start == nil then
break
end
table.insert(subStrings, string.sub(input, init, start - 1))
lastFinish = finish
end
if lastFinish == 0 then
return input
end
table.insert(subStrings, string.sub(input, lastFinish + 1))
return table.concat(subStrings, replacement)
end
local Anonymous = type(OPTIONS.Anonymous) == "table" and OPTIONS.Anonymous
or { UserId = "1", Name = "Roblox" }
for _, chunk in chunks do
chunk.str =
string.gsub(string.gsub(chunk.str, LocalPlayer.UserId, "1"), LocalPlayer.Name, "Roblox")
chunk.str = gsubCaseInsensitive(
string.gsub(chunk.str, LocalPlayer.UserId, Anonymous.UserId),
LocalPlayer.Name,
Anonymous.Name
)
end
end
end