Advertisement
icdb

[ComputerCraft] rednet_log

Oct 13th, 2014
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local function openRednet()
  2.   for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
  3.     if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
  4.       rednet.open(side)
  5.       return side
  6.     end
  7.   end
  8.   print("no modem present")
  9. end
  10.  
  11. side = openRednet()
  12. if side == nil then
  13.   print("no modem found")
  14. else
  15.   while true do
  16.     event, id, message, distance = os.pullEvent("rednet_message")
  17.     local file = fs.open("rednetlog","a")
  18.     file.writeLine(message)
  19.     file.close()
  20.     print(message)
  21.   end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement