icdb icon

[ComputerCraft] rednet_log

icdb | PRO | 10/13/14 09:07:22 PM UTC | 0 ⭐ | 662 👁️ | Never ⏰ | []
Lua |

550 B

|

None

|

0 👍

/

0 👎

local function openRednet()
  for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
    if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
      rednet.open(side) 
      return side
    end
  end
  print("no modem present")
end
 
side = openRednet()
if side == nil then
  print("no modem found")
else
  while true do
    event, id, message, distance = os.pullEvent("rednet_message")
    local file = fs.open("rednetlog","a")
    file.writeLine(message)
    file.close()
    print(message)
  end
end

Comments