Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script updater by THUNDERGROOVE
- args = {...}
- local updateAll = false
- if args[1] == "--all" then
- updateAll = true
- end
- local baseLink = "http://dl.dropbox.com/u/51472257/code/ComputerCraft%20scripts/updater/"
- if not http then print("HTTP is not enabled") os.shutdown() end
- function updateScript(n)
- if n == "Exit Updater" then
- print("")
- else
- local response = http.get(baseLink..s[n])
- if response then
- print("Huzzaaa we got the script")
- else
- print("You broke it.... shutting down")
- os.shutdown()
- end
- local script = response.readAll()
- response.close()
- local file = fs.open(s[n], "w")
- file.write(script)
- file.close()
- print("script updated")
- end
- end
- function menu(m)
- n=1
- l=#m
- while true do
- term.clear()
- term.setCursorPos(1,2)
- for i=1, l, 1 do
- if i==n then print(i, " ["..m[i].."]") else print(i, " ", m[i]) end
- end
- print("Select script to update.")
- a, b= os.pullEventRaw()
- if a == "key" then
- if b==200 and n>1 then n=n-1 end
- if b==208 and n<=l then n=n+1 end
- if b==28 then break end
- end
- end
- term.clear() term.setCursorPos(1,1)
- return n
- end
- print("Grabbing list of scripts...")
- local response = http.get(baseLink.."scripts")
- if response then
- print("Huzzaaa we got the scripts list")
- else
- print("You broke it.... shutting down")
- os.shutdown()
- end
- local scripts = response.readAll()
- response.close()
- local file = fs.open("scripts", "w")
- file.write(scripts)
- file.close()
- shell.run("scripts")
- if updateAll == false then
- option = menu(s)
- if option == #s then
- error()
- else
- updateScript(option)
- end
- else
- for k,v in pairs(s) do
- updateScripts(v)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment