Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This need http API enabled
- local urlD = "http://pastebin.com/raw.php?i="
- local function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function askForDownload()
- clear()
- print("You are going to install CCP server side, wich is a rednet protocol for computercraft.")
- print("Are you sure you want to download and install it ?")
- term.setCursorPos(20, 10)
- print("yes|no")
- local input = string.lower(read())
- if input == "yes" then
- return "true"
- elseif input == "no" then
- return "false"
- else
- print("Bad response")
- end
- end
- local function download()
- clear()
- print("Downloading encryption API...")
- local response = http.request(urlD.."7tpk7XnW")
- local event, url, encryptResp = os.pullEvent()
- if event == "http_success" then
- encryptAPI = encryptResp.readAll()
- encryptResp.close()
- elseif event == "http_failure" then
- error("Can not connect to pastebin")
- end
- clear()
- print("Downloading coreplugin...")
- local response = http.request(urlD.."h8e0CRUh")
- local event, url, coreResp = os.pullEvent()
- if event == "http_success" then
- coreplugin = coreResp.readAll()
- coreResp.close()
- elseif event == "http_failure" then
- error("Can not connect to pastebin")
- end
- clear()
- print("Downloading main program...")
- local response = http.request(urlD.."a6PAyTwh")
- local event, url, mainResp = os.pullEvent()
- if event == "http_success" then
- mainP = mainResp.readAll()
- mainResp.close()
- elseif event == "http_failure" then
- error("Can not connect to pastebin")
- end
- clear()
- print("Downloading GUI API...")
- local response = http.request(urlD.."RZYPqxCp")
- local event, url, GUIResp = os.pullEvent()
- if event == "http_success" then
- GUIAPI = GUIResp.readAll()
- GUIResp.close()
- elseif event == "http_failure" then
- error("Can not connect to pastebin")
- end
- clear()
- print("Installing files...")
- term.setTextColor(colors.red)
- print("WARNING : do not shutdown computer !")
- print(" ")
- term.setTextColor(colors.black)
- fs.makeDir("serverFolder")
- fs.makeDir("/serverFolder/Plugins")
- fs.makeDir("usermade")
- fs.makeDir("/serverFolder/API")
- write(".")
- local mainF = fs.open("Server", "w")
- mainF.write(mainP)
- mainF.close()
- write(".")
- local GUIF = fs.open("/serverFolder/API/gui", "w")
- GUIF.write(GUI API)
- GUIF.close()
- write(".")
- local coreF = fs.open("/serverFolder/Plugins/coreplugin", "w")
- coreF.write(coreplugin)
- coreF.close()
- write(".")
- local encryptF = fs.open("/serverFolder/API/enc", "w")
- encryptF.write(encryptAPI)
- encryptF.close()
- write(".")
- term.setTextColor(colors.green)
- print("Installation done !")
- term.setTextColor(colors.black)
- sleep(2)
- clear()
- end
- if askForDownload() == "true" then
- download()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement