Advertisement
jordyvl

PowerMenu

May 17th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. sid = 0
  2. function clear()
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. end
  6. function menu(id, text)
  7. if sid == id then
  8. write"> "
  9. else
  10. write"* "
  11. end
  12. print(text)
  13. end
  14. while true do
  15. clear()
  16. menu(0, "Reboot")
  17. menu(1, "Shutdown")
  18. event, key = os.pullEvent("key")
  19. if key == 200 then
  20. if sid > 0 then
  21. sid = sid - 1
  22. end
  23. elseif key == 208 then
  24. if sid < 1 then
  25. sid = sid + 1
  26. end
  27. elseif key == 28 then
  28. if sid == 0 then
  29. os.reboot()
  30. elseif sid == 1 then
  31. os.shutdown()
  32. end
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement