Advertisement
kssr3951

remoteLogReceiver

Nov 23rd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- ===============================
  2. -- remoteLogReceiver.lua
  3. -- ===============================
  4. -- -------------------------------
  5. -- config
  6. -- -------------------------------
  7. local MODEM_DIR     = "top"
  8. local FILE_ENABLED  = true
  9. local FILE_NAME     = "remote.log"
  10. local PRINT_ENABLED = true
  11.  
  12. -- -------------------------------
  13. -- application
  14. -- -------------------------------
  15. local function debug(txt)
  16.   local hFile
  17.   if fs.exists(LOG_FILE_NAME) then
  18.     hFile = fs.open(FILE_NAME, "a");
  19.   else
  20.     hFile = fs.open(FILE_NAME, "w");
  21.   end
  22.   hFile.writeLine(txt);
  23.   hFile.close();
  24. end
  25. -- -------------------------------
  26. -- main
  27. -- -------------------------------
  28. print("log_client(remote log receiver)")
  29. print("receive() ...")
  30. while true do
  31.   rednet.open(MODEM_DIR)
  32.   local sdrId, msg, dist = rednet.receive()
  33.   rednet.close()
  34.   if PRINT_ENABLED then
  35.     print(tostring(sdrId)..","..tostring(dist)..","..msg)
  36.   end
  37.   rednet.close(MODEM_DIR)
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement