turtle5204

Untitled

Oct 10th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. --Wojbie's TopLevelCoorutineOverwrite
  2. --Adds a global variable _AfTeRtLcO after running.
  3.  
  4.  
  5.  
  6. --Path to program to run after TLCO - Warning - will not have shell and multishell apis. If nil loads shell or multishell
  7. local sProgram = false
  8. --"/rom/programs/advanced/multishell"
  9. --"rom/programs/shell"
  10.  
  11. if _AfTeRtLcO then
  12. shell.run("shell")
  13. end
  14.  
  15. local m = _G.os.shutdown
  16. local first=false
  17. function _G.os.shutdown()
  18. if first then first=false return end
  19. _G.os.shutdown = m
  20. _G._AfTeRtLcO = true
  21. term.redirect(term.native())
  22. local ok, err = pcall( function()
  23. parallel.waitForAny(
  24. function()
  25. loadfile( "/rom/programs/shell" )()
  26. end,
  27. function()
  28.  
  29. os.loadAPI("/rednet")
  30. rednet.run()
  31. end
  32. )
  33. end )
  34.  
  35. -- If the crap errored, let the user read it.
  36. term.redirect( term.native() )
  37. if not ok then
  38. printError( err )
  39. pcall( function()
  40. term.setCursorBlink( false )
  41. print( "Press any key to continue" )
  42. os.pullEvent( "key" )
  43. end )
  44. end
  45. os.shutdown()
  46. end
  47.  
  48. local t = _G.type
  49. function _G.type(A)
  50. if A=="Breakout" then print("Breaking") _G.type=t os.queueEvent("key") error("Breaking",2)
  51. else return t(A) end
  52. end
  53.  
  54. shell.exit()
  55. os.queueEvent("key")
  56. os.queueEvent("modem_message", "Breakout", 1, 1, "Breakout" )
  57. error("Breaking",2)
Advertisement
Add Comment
Please, Sign In to add comment