Wojbie

TLCO

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