Advertisement
Leo_Verto

sponge

Jan 4th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. rednet.open("top")
  2.  
  3. local tArgs = {...}
  4. local server = 0
  5. local client = 0
  6. local m = peripheral.wrap("left")
  7.  
  8. if #tArgs >= 2 then
  9.   server = tonumber(tArgs[1])
  10.   client = tonumber(tArgs[2])
  11. else
  12.   print([[You can also use "sponge <server> <client>" to only listen for specific ids.]])
  13. end
  14.  
  15. term.clear()
  16. term.setCursorPos(1,1)
  17. m.clear()
  18. m.setCursorPos(1,1)
  19. print("Listening....")
  20.  
  21. while true do
  22.   id, msg = rednet.receive()
  23.   if server~=0 and client~=0 then
  24.     if id==server or id==client then
  25.           print(id..":"..msg)
  26.     log = fs.open("log", "a")
  27.     log.writeLine(id..":"..msg)
  28.     log.close()
  29.     end
  30.   else
  31.     print(id..":"..msg)
  32.     log = fs.open("log", "a")
  33.     log.writeLine(id..":"..msg)
  34.     log.close()
  35.   end
  36.   term.redirect(m)
  37.   term.restore()
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement