refactor: enhance status message handling for dual-mode channel compatibility

This commit is contained in:
MayaTheShy
2026-03-26 16:19:33 -04:00
parent ffb6d679c0
commit f1c8f08272

View File

@@ -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