ZeeDerp

ClosePlayers Startup

Jan 2nd, 2021 (edited)
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function os.apullEvent(_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.  sleep(3)
  11. local function get(paste)
  12.     local response = http.get(
  13.         "http://pastebin.com/raw.php?i="..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"},
  47.             [2]= {['programName']="start", ['pastebin']="MJivXq3U"},
  48. }
  49. function updateOrDownload()
  50.     for _,data in pairs(programs) do
  51.         downloadProgram(data['pastebin'], data['programName'])
  52.     end
  53. end
  54. function clearTerminal()
  55.     term.setCursorPos(1,1)
  56.     term.clear()
  57. end
  58. function startProgram()
  59.     clearTerminal()
  60.     print("Started!")
  61.     shell.run("start")
  62. end
  63. clearTerminal()
  64. print("Starting...")
  65. sleep(0.2)
  66. if( not pcall(updateOrDownload) ) then
  67.     print("An error has occurred, PM me on discord: GravityCube#3550. Or wait 30 seconds to try again")
  68.     sleep(30)
  69.     os.reboot()
  70. end
  71.  
  72. local ok, err = pcall(startProgram)
  73. print(err)
  74. print("An error has occurred, PM me on discord: GravityCube#3550.")
  75.  
  76. sleep(10)
  77. os.reboot()
Add Comment
Please, Sign In to add comment