Advertisement
ComputerMan123

Neptune Installer [BETA]

Nov 29th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. --[[
  2. Neptune Setup
  3. By: houseofkraft
  4. ]]--
  5.  
  6. files = {
  7. [1] = {
  8. "https://raw.githubusercontent.com/CoolMan119/Neptune/master/System/Boot/boot1",
  9. "/System/Boot/boot1"
  10. },
  11. [2] = {
  12. "https://raw.githubusercontent.com/CoolMan119/Neptune/master/System/Boot/boot2",
  13. "/System/Boot/boot2"
  14. }
  15. }
  16.  
  17. if not term.isColor() or not term.isColor then
  18. printError("You need a advanced computer to run Neptune!")
  19. error()
  20. end
  21.  
  22.  
  23. -- Functions
  24. function center(text)
  25. local x, y = term.getSize()
  26. local x2, y2 = term.getCursorPos()
  27. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  28. write(text)
  29. end
  30.  
  31. function centerBoth(text)
  32. local w, h = term.getSize()
  33. term.setCursorPos(math.floor(w / 2 - text:len() / 2 + .5), math.floor(h / 2 + .5))
  34. write(text)
  35. end
  36.  
  37. function getCenterPos(text)
  38. local x, y = term.getCursorPos()
  39. local nx = math.ceil(x / 2 - (text:len() / 2))
  40. return nx, y
  41. end
  42.  
  43. function getCenterBothPos(text)
  44. local w, h = term.getSize()
  45. return math.floor(w / 2 - text:len() / 2 + .5), math.floor(h / 2 + .5)
  46. end
  47.  
  48. -- Init
  49. term.setBackgroundColor( colors.cyan )
  50. term.clear()
  51. term.setCursorPos( 1,1 )
  52. center( "Neptune" )
  53. centerBoth( "The new way to use a OS" )
  54. local x, y = getCenterBothPos( "Install" )
  55. paintutils.drawLine( x + 2, y + 1, x - 2, y + 1, colors.lightBlue )
  56. term.setCursorPos( x + 2, y + 1 )
  57. term.setTextColor( colors.blue )
  58. local xx, yy = term.getCursorPos()
  59. term.setCursorPos(xx - 3, yy)
  60.  
  61. local preX = xx - 3
  62. local preY = yy
  63.  
  64. write( "Install" )
  65. while true do
  66. local event, button, nx, ny = os.pullEvent( "mouse_click" )
  67. if button == 1 then
  68. if nx >= preX and ny == preY and nx <= preX + #"install" then
  69. break
  70. end
  71. end
  72. end
  73. term.setBackgroundColor(colors.cyan)
  74. term.setTextColor(colors.blue)
  75. term.clear()
  76. term.setCursorPos( 1,1 )
  77. center( "Neptune" )
  78. centerBoth( "Installing" )
  79. for k,v in pairs( files ) do
  80. os.sleep(1)
  81. -- Writing the file on the screen
  82. local x, y = getCenterPos( v[2] )
  83. term.setCursorPos( x, y + 2 )
  84. write( v[2] )
  85. local h = http.get( v[1] )
  86. f = fs.open( v[2], 'w')
  87. f.write( h.readAll() )
  88. end
  89.  
  90. -- Rebooting
  91. term.clear()
  92. term.setCursorPos( 1,1 )
  93. center( "Neptune" )
  94. centerBoth( "Your PC will reboot in 3 seconds" )
  95. os.sleep(1)
  96. term.clear()
  97. term.setCursorPos( 1,1 )
  98. center( "Neptune" )
  99. centerBoth( "Your PC will reboot in 2 seconds" )
  100. os.sleep(1)
  101. term.clear()
  102. term.setCursorPos( 1,1 )
  103. center( "Neptune" )
  104. centerBoth( "Your PC will reboot in 1 second" )
  105. os.sleep(1)
  106. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement