Rednet send missing protocol
minerbadd opened this issue ยท 3 comments
This is in CC:T 1.81.1, MC 1.12.2, MCP 9.42, Plethora 1.1.13
Filtering for a rednet protocol with rednet.receive() yields no messages.
(The workaround of dropping the filter argument works ok.)
Filtering would be useful where the workaround isn't appropriate.
Are lines 84 and 85 of apis/rednet.lua missing a reference to sProtocol?
The functions that work are as follows:
local function send()
local hosts = {rednet.lookup("CWQ")}
core.status(1, "Hosting "..#hosts..": ", table.unpack(hosts))
for _, id in ipairs(hosts) do rednet.send(id, os.getComputerLabel(), "CWQ") end
end
local function post()
while true do
local playerID = rednet.receive(); -- protocol filtering seems broken
local turtleLabel = os.getComputerLabel() -- **fails if protocol filter "CWQ" is specified**
end
end
rednet.send(playerID, turtleLabel, "CWQ")
Hope this turns out to be helpful (and sorry if it doesn't)
I'm afraid I'm unable to reproduce this - tested running the following code on computer A:
peripheral.find("modem", rednet.open)
print(rednet.receive("some-protocol"))
and this on B:
peripheral.find("modem", rednet.open)
rednet.send(135, "Hello", "some-protocol")
The protocol should be bundled as part of tMessage
(see here), so I don't think that's the issue.
It may be worth checking the message is actually sent to the correct computer (and that it starts receiving messages before the message is sent). I assume you're calling rednet.host
elsewhere on the receiving computer?
Thanks... as you suggested there was a race between sending the request messages and turtles ready to receive the message (before the message was sent). Eliminating that asynchrony resolved the issue. Sorry for the fire drill.