Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Constants for the update process
- local pastebinCode = "gQV6Jvhv" -- Replace with your actual Pastebin code
- local scriptName = "jakeExcavate"
- local version = 0.1 -- Increment this version in your Pastebin script when updated
- -- Function to download and update from Pastebin
- function updateFromPastebin()
- local response = http.get("https://pastebin.com/raw/" .. pastebinCode)
- if response then
- local scriptContent = response.readAll()
- response.close()
- local file = fs.open(scriptName, "w")
- file.write(scriptContent)
- file.close()
- print(scriptName.. " - Update downloaded. Restarting script...")
- os.sleep(1) -- Short pause before reboot
- os.reboot()
- else
- print("Failed to check for updates.")
- end
- end
- -- Function to check for new updates and apply them
- function checkForUpdates()
- local response = http.get("https://pastebin.com/raw/" .. pastebinCode)
- if response then
- local scriptContent = response.readAll()
- response.close()
- -- Check if the first line in the updated file contains a new version number
- local remoteVersion = tonumber(string.match(scriptContent, "%-%- Version: (%d+%.%d+)"))
- if remoteVersion and remoteVersion > version then
- print(scriptName.. " - New version found: " .. remoteVersion)
- updateFromPastebin()
- else
- print(scriptName.. " - Running the latest version.")
- end
- else
- print("Failed to connect to Pastebin for update check.")
- end
- end
- -- Call this function at the start of your script
- checkForUpdates()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement