Advertisement
GravityCube

MonitorDisplay Startup

Nov 13th, 2020
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function os.pullEvent(_sFilter)
  2.     local params = {}
  3.     params = {os.pullEventRaw(_sFilter)}
  4.     event = params[1]
  5.     if event == "terminate" then
  6.         print("If you want to see the code PM me on discord: GravityCube#3550")
  7.     end
  8.     return unpack(params)
  9. end
  10.  
  11. local function get(paste)
  12.     local response = http.get(
  13.         "https://pastebin.com/raw/"..textutils.urlEncode( paste )
  14.     )
  15.        
  16.     if response then
  17.         print( "Success." )
  18.         sleep(0.1)
  19.        
  20.         local sResponse = response.readAll()
  21.         response.close()
  22.         return sResponse
  23.     else
  24.         error( "Failed." )
  25.     end
  26. end
  27.  
  28. function downloadProgram(sCode, sPath)
  29.     if fs.exists( sPath ) then
  30.         print( "Updating(" .. sPath .. ")..." )
  31.         fs.delete(sPath)
  32.     else
  33.         print( "Downloading(" .. sPath .. ")..." )
  34.     end
  35.     sleep(0.1)
  36.    
  37.     -- GET the contents from pastebin
  38.     local res = get(sCode)
  39.     if res then        
  40.         local file = fs.open( sPath, "w" )
  41.         file.write( res )
  42.         file.close()
  43.     end
  44. end
  45.  
  46. programs = {[1]= {['programName'] = "gcapi", ['pastebin']="0uAaAcrW"}, [2]= {['programName']="start", ['pastebin']="6akzvPVk"}}
  47.  
  48. function updateOrDownload()
  49.     for _,data in pairs(programs) do
  50.         downloadProgram(data['pastebin'], data['programName'])
  51.     end
  52. end
  53. function clearTerminal()
  54.     term.setCursorPos(1,1)
  55.     term.clear()
  56. end
  57. function startProgram()
  58.     clearTerminal()
  59.     print("Started!")
  60.     shell.run("start")
  61. end
  62. clearTerminal()
  63. print("Starting...")
  64. sleep(0.2)
  65. if( not pcall(updateOrDownload) ) then
  66.     print("An error has occurred, PM me on discord: GravityCube#3550. Or wait 30 seconds to try again")
  67.     sleep(30)
  68.     os.reboot()
  69. end
  70.  
  71. local ok, err = pcall(startProgram)
  72. print(err)
  73. print("An error has occurred, PM me on discord: GravityCube#3550.")
  74.  
  75. sleep(10)
  76. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement