Guest User

Untitled

a guest
Nov 17th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1.  
  2. function printUsage()
  3. print( "Usage: redrec <run as an app[yes/no]> <run  on monitor[yes/no]> <side of monitor>" )
  4. return
  5. end
  6.  
  7. local tArgs = { ... }
  8. if #tArgs < 2 then
  9. printUsage()
  10. return
  11. end
  12.  
  13. local sApp = tArgs[1]
  14. local sMon = tArgs[2]
  15. local sSide = tArgs[3]
  16.  
  17. if sMon == "yes" then
  18. if sSide == nil then
  19. print("Please enter the side of the monitor.")
  20. end
  21. end
  22.  
  23. rednet.open("left")
  24. senderId, message, distance = rednet.receive()
  25.  
  26. if sApp == "yes" then
  27.  
  28. if sMon == "yes" then
  29.  
  30. if message == "alongtimeago" then
  31. local monitor = peripheral.wrap( sSide )
  32. term.redirect( monitor )
  33. os.run({}, "rom/programs/secret/alongtimeago")
  34. term.restore()
  35. end
  36.  
  37. local monitor = peripheral.wrap( sSide )
  38. term.redirect( monitor )
  39. shell.run( message, select(3, ... ) )
  40. term.restore()
  41.  
  42. else
  43.  
  44. local sPath = shell.resolveProgram( message )
  45. if sPath == nil then
  46. print( "No such program: "..message )
  47. return
  48. end
  49.  
  50. shell.run( message )
  51. end
  52.  
  53. else
  54.  
  55. if sMon == "yes" then
  56. local monitor = peripheral.wrap( sSide )
  57. term.redirect( monitor )
  58. term.write( message )
  59. term.restore()
  60.  
  61. else
  62. print("Message from #" ..senderId.. ": " ..message )
  63. end
  64. end
  65.  
  66.  
  67. rednet.close("left")
Add Comment
Please, Sign In to add comment