Marlingaming

Heimbriech Tablet OS - Shutdown Handler

Sep 9th, 2021 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. local oldPull = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3. --this program basically deals with all the chores of shutting down the OS and making sure all files are put away cleanly
  4. local tArg = {...}
  5. local CompletionAction = tArg[1]
  6. local AllowReturn = tArg[2]
  7. local Stage = 0
  8.  
  9. start()
  10.  
  11. function start()
  12. term.clear()
  13. term.setBackground("blue")
  14. Stage_one()
  15. end
  16.  
  17. function Stage_one()
  18. print("Shutdown Handler")
  19. if AllowReturn == true then
  20. print("Shutting Down, to cancel please Press B within 30 seconds")
  21. until Stage == 1 or Stage == -1 do
  22. local input = read()
  23. if input == "b" then
  24. Stage == -1
  25. end
  26. end
  27. else
  28. Stage == 1
  29. end
  30. if Stage == -1 then
  31. sleep(10)
  32. shell.run(".Menu")
  33. else if Stage == 1 then
  34. Stage_two()
  35. end
  36. end
  37.  
  38. function Stage_two()
  39. Completion()
  40. end
  41.  
  42. function Completion()
  43. if CompletionAction == "Restart" then
  44. os.reboot()
  45. else if CompletionAction == "Shutdown" then
  46. os.shutdown()
  47. end
  48. end
  49. os.pullEvent = oldPull
Add Comment
Please, Sign In to add comment