Advertisement
ecoMeco

[ComputerCraft] Goodbye (A Shutdown/Reboot program)

May 2nd, 2014
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. --Centering Text
  2. local function center(text)
  3.   local x,y = term.getSize()
  4.   local x2,y2 = term.getCursorPos()
  5.   term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  6.   write(text)
  7. end
  8.  
  9. local arg = { ... }
  10.  
  11. if arg[1] == "-s" then
  12. --Shutdown
  13.   term.setBackgroundColor(colors.lightBlue)
  14.   term.clear()
  15.   center("Shutting Down")
  16.   sleep(1)
  17.   os.shutdown()
  18. elseif arg[1] == "-r" then
  19. --Reboot
  20.   term.setBackgroundColor(colors.lightBlue)
  21.   term.clear()
  22.   center("Rebooting")
  23.   sleep(1)
  24.   os.reboot()
  25. elseif arg[1] == "-h" then
  26. --Help
  27.  print("goodbye -s      SHUTDOWN")
  28.  print("goodbye -r      RESTART")
  29.  
  30. else
  31. --No args
  32.   error("type \"goodbye -h\" to list arguments")
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement