mast3rillusion

install.lua

Jul 27th, 2021 (edited)
239
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tablelength(T)
  2.     local count = 0
  3.     for _ in pairs(T) do count = count + 1 end
  4.     return count
  5. end
  6.  
  7. function Pastebin( sCode, sPath )
  8.     local response = http.get("http://pastebin.com/raw/"..sCode)
  9.     if response then
  10.         local sResponse = response.readAll()
  11.         response.close()
  12.         local file = fs.open( sPath, "w" )
  13.         file.write( sResponse )
  14.         file.close()
  15.     end
  16. end
  17.  
  18. scripts = {}
  19. tmpScript = {}
  20. tmpScript1 = {}
  21. tmpScript2 = {}
  22. tmpScript3 = {}
  23. tmpScript4 = {}
  24. tmpScript5 = {}
  25. tmpScript6 = {}
  26.  
  27. tmpScript["script"] = "settings.lua"
  28. tmpScript["code"] = "x3AGVmrE"
  29. table.insert(scripts, tmpScript)
  30.  
  31. tmpScript1["script"] = "buttons.lua"
  32. tmpScript1["code"] = "n0TCr7i3"
  33. table.insert(scripts, tmpScript1)
  34.  
  35. tmpScript2["script"] = "notifications.lua"
  36. tmpScript2["code"] = "Zpk9s7Zz"
  37. table.insert(scripts, tmpScript2)
  38.  
  39. tmpScript3["script"] = "redstone.lua"
  40. tmpScript3["code"] = "gZuRAVWi"
  41. table.insert(scripts, tmpScript3)
  42.  
  43. tmpScript4["script"] = "power.lua"
  44. tmpScript4["code"] = "1u9eqabU"
  45. table.insert(scripts, tmpScript4)
  46.  
  47. tmpScript5["script"] = "machines.lua"
  48. tmpScript5["code"] = "TNYbB6P2"
  49. table.insert(scripts, tmpScript5)
  50.  
  51. tmpScript6["script"] = "startup.lua"
  52. tmpScript6["code"] = "Mpqk3Tvi"
  53. table.insert(scripts, tmpScript6)
  54.  
  55. if not fs.exists("graphics.lua") then
  56.     Pastebin("ecz1XjZa","graphics.lua")
  57. end
  58.  
  59. if not fs.exists("sliders.lua") then
  60.     Pastebin("xduvSaJ4","sliders.lua")
  61. end
  62.  
  63. os.loadAPI("graphics.lua")
  64. os.loadAPI("sliders.lua")
  65.  
  66. w,h = term.getSize()
  67. length = tablelength(scripts)
  68.  
  69. sliders.createSlider("installSlider", 2, 8, w-2, 1, colors.lime, colors.red)
  70.  
  71. installing = true
  72.  
  73. while installing do
  74.  
  75.     for k,v in pairs(scripts) do
  76.         graphics.fillScreen(colors.green)
  77.         term.setCursorPos(2,7)
  78.         term.setBackgroundColor( colors.green )
  79.         term.clearLine()
  80.         notification = graphics.label:new()
  81.         notification.text = "Installing " .. v.script
  82.         len = string.len(notification.text)
  83.         notification.x = (w/2) - (len/2) + 1
  84.         notification.y = 7
  85.         notification.bkgColor = colors.green
  86.         notification.draw(notification)
  87.  
  88.         installPercentage = (k / length) * 100
  89.         sliders.updateSlider("installSlider", installPercentage)
  90.         sliders.draw()
  91.  
  92.         if not fs.exists(v.script) then
  93.             Pastebin(v.code,v.script)
  94.         end
  95.  
  96.     end
  97.     os.reboot()
  98.  
  99. end
RAW Paste Data