fix: replace custom event wake-up with polling, remove craftItem double-capture

Two robustness improvements to the Network capture/processor split:

1. Processor wake-up: replaced os.queueEvent('network_queued') /
   os.pullEvent('network_queued') with sleep(0) polling. Custom events
   can be consumed by other coroutines (e.g. craftItem's unfiltered
   os.pullEvent()) or swallowed by the OS event layer. Polling the
   shared queue every tick is simpler and guaranteed reliable.

2. craftItem: removed ORDER_CHANNEL message buffering and re-queuing.
   With the dedicated Network-capture task, ORDER_CHANNEL messages are
   already safely captured into networkQueue. The old buffering caused
   double-capture: capture task adds to queue, craftItem also buffers,
   then re-queues via os.queueEvent -> capture captures again -> dup.
   The commandId dedup caught these, but removing the source is cleaner.
This commit is contained in:
MayaTheShy
2026-03-28 23:40:09 -04:00
parent 36612ecc9f
commit ec1a681924
2 changed files with 2 additions and 9 deletions

View File

@@ -646,7 +646,6 @@ local function main()
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
if channel == cfg.ORDER_CHANNEL and type(message) == "table" then
table.insert(networkQueue, { replyChannel = replyChannel, message = message })
os.queueEvent("network_queued")
end
end
end),
@@ -658,7 +657,7 @@ local function main()
end
while true do
if #networkQueue == 0 then
os.pullEvent("network_queued")
sleep(0)
end
while #networkQueue > 0 do
local entry = table.remove(networkQueue, 1)