refactor: enhance status message handling for dual-mode channel compatibility
This commit is contained in:
@@ -631,10 +631,12 @@ parallel.waitForAny(
|
|||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
-- Status receiver
|
-- Status receiver
|
||||||
|
-- Uses Channels.match() for dual-mode safety: accepts status on
|
||||||
|
-- both legacy (102) and target (4212) channels during migration.
|
||||||
while true do
|
while true do
|
||||||
local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
|
local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
|
||||||
|
|
||||||
if channel == STATUS_CHANNEL and type(message) == "table" and message.type == "status" then
|
if Channels.match('remoteturtle.status', channel) and type(message) == "table" and message.type == "status" then
|
||||||
-- Update or add turtle
|
-- Update or add turtle
|
||||||
local found = false
|
local found = false
|
||||||
for i, t in ipairs(turtles) do
|
for i, t in ipairs(turtles) do
|
||||||
@@ -660,7 +662,7 @@ parallel.waitForAny(
|
|||||||
end
|
end
|
||||||
|
|
||||||
draw()
|
draw()
|
||||||
elseif channel == CHANNEL_RECEIVE and type(message) == "table" then
|
elseif Channels.match('remoteturtle.response', channel) and type(message) == "table" then
|
||||||
-- State change confirmation or other response
|
-- State change confirmation or other response
|
||||||
if message.type == "state_changed" and message.turtleID then
|
if message.type == "state_changed" and message.turtleID then
|
||||||
for i, t in ipairs(turtles) do
|
for i, t in ipairs(turtles) do
|
||||||
|
|||||||
Reference in New Issue
Block a user