Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function os.apullEvent(_sFilter)
- local params = {}
- params = {os.pullEventRaw(_sFilter)}
- event = params[1]
- if event == "terminate" then
- print("If you want to see the code PM me on discord: GravityCube#3550")
- end
- return unpack(params)
- end
- sleep(3)
- local function get(paste)
- local response = http.get(
- "http://pastebin.com/raw.php?i="..textutils.urlEncode( paste )
- )
- if response then
- print( "Success." )
- sleep(0.1)
- local sResponse = response.readAll()
- response.close()
- return sResponse
- else
- error( "Failed." )
- end
- end
- function downloadProgram(sCode, sPath)
- if fs.exists( sPath ) then
- print( "Updating(" .. sPath .. ")..." )
- fs.delete(sPath)
- else
- print( "Downloading(" .. sPath .. ")..." )
- end
- sleep(0.1)
- -- GET the contents from pastebin
- local res = get(sCode)
- if res then
- local file = fs.open( sPath, "w" )
- file.write( res )
- file.close()
- end
- end
- programs = {[1]= {['programName'] = "gcapi", ['pastebin']="0uAaAcrW"},
- [2]= {['programName']="start", ['pastebin']="MJivXq3U"},
- }
- function updateOrDownload()
- for _,data in pairs(programs) do
- downloadProgram(data['pastebin'], data['programName'])
- end
- end
- function clearTerminal()
- term.setCursorPos(1,1)
- term.clear()
- end
- function startProgram()
- clearTerminal()
- print("Started!")
- shell.run("start")
- end
- clearTerminal()
- print("Starting...")
- sleep(0.2)
- if( not pcall(updateOrDownload) ) then
- print("An error has occurred, PM me on discord: GravityCube#3550. Or wait 30 seconds to try again")
- sleep(30)
- os.reboot()
- end
- local ok, err = pcall(startProgram)
- print(err)
- print("An error has occurred, PM me on discord: GravityCube#3550.")
- sleep(10)
- os.reboot()
Add Comment
Please, Sign In to add comment