Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Neptune Setup
- By: houseofkraft
- ]]--
- files = {
- [1] = {
- "https://raw.githubusercontent.com/CoolMan119/Neptune/master/System/Boot/boot1",
- "/System/Boot/boot1"
- },
- [2] = {
- "https://raw.githubusercontent.com/CoolMan119/Neptune/master/System/Boot/boot2",
- "/System/Boot/boot2"
- }
- }
- if not term.isColor() or not term.isColor then
- printError("You need a advanced computer to run Neptune!")
- error()
- end
- -- Functions
- function center(text)
- local x, y = term.getSize()
- local x2, y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text)
- end
- function centerBoth(text)
- local w, h = term.getSize()
- term.setCursorPos(math.floor(w / 2 - text:len() / 2 + .5), math.floor(h / 2 + .5))
- write(text)
- end
- function getCenterPos(text)
- local x, y = term.getCursorPos()
- local nx = math.ceil(x / 2 - (text:len() / 2))
- return nx, y
- end
- function getCenterBothPos(text)
- local w, h = term.getSize()
- return math.floor(w / 2 - text:len() / 2 + .5), math.floor(h / 2 + .5)
- end
- -- Init
- term.setBackgroundColor( colors.cyan )
- term.clear()
- term.setCursorPos( 1,1 )
- center( "Neptune" )
- centerBoth( "The new way to use a OS" )
- local x, y = getCenterBothPos( "Install" )
- paintutils.drawLine( x + 2, y + 1, x - 2, y + 1, colors.lightBlue )
- term.setCursorPos( x + 2, y + 1 )
- term.setTextColor( colors.blue )
- local xx, yy = term.getCursorPos()
- term.setCursorPos(xx - 3, yy)
- local preX = xx - 3
- local preY = yy
- write( "Install" )
- while true do
- local event, button, nx, ny = os.pullEvent( "mouse_click" )
- if button == 1 then
- if nx >= preX and ny == preY and nx <= preX + #"install" then
- break
- end
- end
- end
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.blue)
- term.clear()
- term.setCursorPos( 1,1 )
- center( "Neptune" )
- centerBoth( "Installing" )
- for k,v in pairs( files ) do
- os.sleep(1)
- -- Writing the file on the screen
- local x, y = getCenterPos( v[2] )
- term.setCursorPos( x, y + 2 )
- write( v[2] )
- local h = http.get( v[1] )
- f = fs.open( v[2], 'w')
- f.write( h.readAll() )
- end
- -- Rebooting
- term.clear()
- term.setCursorPos( 1,1 )
- center( "Neptune" )
- centerBoth( "Your PC will reboot in 3 seconds" )
- os.sleep(1)
- term.clear()
- term.setCursorPos( 1,1 )
- center( "Neptune" )
- centerBoth( "Your PC will reboot in 2 seconds" )
- os.sleep(1)
- term.clear()
- term.setCursorPos( 1,1 )
- center( "Neptune" )
- centerBoth( "Your PC will reboot in 1 second" )
- os.sleep(1)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement