Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fs = require("filesystem")
- local internet = require("internet")
- local computer = require("computer")
- local file = {
- name = "reactor.lua",
- url = "https://raw.githubusercontent.com/NusanHuh/uc_big_reactor/refs/heads/main/reactor.lua"
- }
- local home = "/home"
- fs.makeDirectory(home)
- local function downloadFile(file)
- local path = home .. "/" .. file.name
- local handle, reason = internet.request(file.url)
- if not handle then
- io.stderr:write("Failed to download " .. file.name .. ": " .. tostring(reason) .. "\n")
- return false
- end
- local f = io.open(path, "w")
- for chunk in handle do f:write(chunk) end
- f:close()
- return true
- end
- local function isDownloaded()
- return fs.exists(home .. "/" .. file.name)
- end
- print("Downloading file to /home ...")
- print("→ " .. file.name)
- if downloadFile(file) then
- print(" Download complete")
- else
- print(" Download failed")
- end
- if isDownloaded() then
- local autorun = "/autorun.lua"
- local f = io.open(autorun, "w")
- f:write('os.execute("/home/reactor.lua")\n')
- f:close()
- print("\nFile downloaded successfully!")
- print("'autorun.lua' created. The computer will auto-run reactor.lua at startup!")
- print("Rebooting now...")
- os.sleep(2)
- computer.shutdown(true)
- else
- print("\nDownload failed. autorun.lua was not created.")
- end
Advertisement
Add Comment
Please, Sign In to add comment