If the remote server is down, it defaults to the last known stable local version. Implementation Example (Lua logic):
This feature would allow the script to compare local file hashes against a remote "Stable" manifest. If an update fails or causes errors, the updater can download a verified previous version from a repository like GitHub . Key Components:
This ensures that if a new update breaks the user’s experience, they can instantly revert to a stable version. Proposed Feature: Version Rollback & Integrity Check BetterXperienceAutoUpdater.lua
Users are more likely to enable auto-updates if they know they can easily undo them.
Uses a simple checksum to ensure the downloaded file isn't corrupted before execution. If the remote server is down, it defaults
Prevents "bricked" scripts if an update contains a syntax error.
Following Lua Optimization Tips , you can use local variables for these file operations to keep the updater fast and lightweight. Lua Optimization Tips - Luanti Documentation Key Components: This ensures that if a new
local CurrentVersion = "1.2.0" local UpdateURL = "https://github.com" local function CheckForUpdate() -- Logic to fetch remote version local remoteData = request({Url = UpdateURL, Method = "GET"}).Body local latest = decode_json(remoteData).tag_name if latest ~= CurrentVersion then print("Update found: " .. latest .. ". Backing up " .. CurrentVersion) writefile("BetterXperience_Backup.lua", readfile("BetterXperience.lua")) -- Trigger download of new version end end local function Rollback() if isfile("BetterXperience_Backup.lua") then writefile("BetterXperience.lua", readfile("BetterXperience_Backup.lua")) warn("Rollback successful. Please restart the script.") end end Use code with caution. Copied to clipboard Why this adds value: