Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = "0.12"
- if not http then
- printError( "Script requires http API" )
- printError( "Set http_enable to true in ComputerCraft.cfg" )
- return
- end
- function get(url)
- write( "Connecting to server... " )
- http.request("https://meinkraftcult.repl.co/"..url)
- local requesting = true
- while requesting do
- local event, url, sourceText = os.pullEvent()
- if event == "http_success" then
- local respondedText = sourceText.readAll()
- sourceText.close()
- requesting = false
- return respondedText
- elseif event == "http_failure" then
- print(url)
- printError("Server didn't respond.")
- requesting = false
- end
- end
- end
- function install(program,xpath)
- if fs.exists(xpath) then fs.delete(xpath) end
- local res = get(program..".lua")
- if res then
- local file = fs.open(xpath, "w" )
- file.write( res )
- file.close()
- print( "Downloaded as "..fs.getName(xpath) )
- end
- end
- -- Update
- if get("apt/version") ~= version then
- install("apt/get","apt")
- end
- -- Run
- local Args = {...}
- if #Args == 2 then
- install(unpack(Args))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement