QuickMuffin8783

Untitled

May 5th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. -- --- ----  Boot System v1.x  ---- --- --
  2.  
  3. os.loadAPI("gui.lua")
  4.  
  5. local dir = "/win/win"
  6.  
  7. local function bootSequence()
  8.     if gui.getButtonState( "cancel-button" ) == true then
  9.     gui.setLabelText( "load-label" , "Canceling boot..." )
  10.     os.sleep(1)
  11.     gui.clearAllObjects()
  12.     term.setCursorPos(1,1)
  13.     print( "Canceled direct boot to" )
  14.     print( "/CraftOS" .. dir )
  15.     os.sleep(2)
  16.     term.clear()
  17.     term.setCursorPos(1,1)
  18.     print( "To boot, type \"reboot\"." )
  19.     print( "Boot System" )
  20.     os.pullEvent( "ternimate" )
  21.     end
  22.   gui.updateAll()
  23. end
  24.  
  25. local w, h = term.getSize()
  26. local prog = 100
  27. local timer = 0
  28.  
  29. gui.newLabel( "title-1" , "Boot System" , 1 , 1 , w - 8 , 1 , colors.blue )
  30. gui.newButton( "cancel-boot" , "Cancel", w - 8 , 1 , 8 , 1, nil, nil, colors.pink, colors.red, false)
  31.  
  32. gui.newLabel( "boot-dir-title" , "Boot Directory" , 2 , 3 , w - 2 , 1 , colors.blue )
  33. gui.newLabel( "boot-dir" , "/CraftOS" .. dir , 2 , 5 , w - 2 , 2 , colors.gray )
  34. gui.newBar( "load-bar" , 1 , h - 2 , w , 1 , colors.lightBlue , colors.blue , 0)
  35. gui.newLabel( "load-label , "Invalid label" , 1 , h - 3 , w , 1 , colors.blue )
  36. os.sleep(0.01)
  37. gui.setLabelText( "load-label" , "Press F1 to cancel. Press enter to boot." )
  38.  
  39. gui.updateAll()
  40. timer = 5
  41. repeat
  42.    bootSequence()
  43.    os.sleep( 0.1)
  44.    timer = timer - 0.1
  45. until timer < 0.1
  46. repeat
  47.    bootSequence()
  48.    gui.setBarValue( "load-bar" , prog )
  49.    gui.setLabelText( "load-label" , "Booting  OS in " .. prog / 10 .. " seconds..." )
  50.    prog = prog - 1
  51.    os.sleep(0.1)
  52. until prog < 1
  53.  
  54. gui.clearAllObjects()
  55.  
  56. shell.exit()
Add Comment
Please, Sign In to add comment