Advertisement
Daraketh

systemBoot

May 22nd, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. local pullEvent = os.pullEvent
  2. local flag = true
  3.  
  4. local c1 = peripheral.wrap("computer_1")
  5. local c2 = peripheral.wrap("computer_2")
  6. local c3 = peripheral.wrap("computer_4")
  7.  
  8. local input
  9.  
  10. function boot()
  11.  
  12.   c1.turnOn()
  13.   c2.turnOn()
  14.   c3.turnOn()
  15.  
  16. end
  17.  
  18. function readInput()
  19.  
  20.   input = read()
  21.  
  22.   if input == "boot" then
  23.     boot()
  24.     print("Booting system")
  25.     sleep(1)
  26.   end
  27.  
  28.   if input == "adminmodegogo" then
  29.     flag = false
  30.     os.pullEvent = pullEvent
  31.     print("Hold Ctrl + T to break")
  32.   end
  33.  
  34.   if input == "shutdownmeow" then
  35.     print("Shutting down")
  36.     c1.shutdown()
  37.     c2.shutdown()
  38.     c3.shutdown()
  39.     sleep(1)
  40.     os.shutdown()
  41.   end
  42.  
  43. end
  44.  
  45. function start()
  46.  
  47.   if flag then
  48.     term.clear()
  49.     term.setCursorPos(1,1)
  50.     print("Type boot to start system")
  51.   end
  52.  
  53.   if flag then
  54.     os.pullEvent = os.pullEventRaw
  55.   end
  56.  
  57. end
  58.  
  59. while true do
  60.  
  61.   start()
  62.   readInput()
  63.  
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement