diff --git a/turtle.lua b/turtle.lua index 95aa52e..da39821 100644 --- a/turtle.lua +++ b/turtle.lua @@ -53,6 +53,8 @@ if not modem then error("No wireless modem found!") end modem.open(CHANNEL_RECEIVE) +print("📻 Modem opened on channel " .. CHANNEL_RECEIVE) +print(" Listening for commands...") print("Advanced Mining Turtle System") print("ID: " .. os.getComputerID()) @@ -994,12 +996,34 @@ parallel.waitForAny( function() -- Command processing loop + print("🎧 Command listener started - waiting for messages...") while true do local event, side, channel, replyChannel, message = os.pullEvent() - if event == "modem_message" then - print("Modem message on channel " .. channel) + -- Log ALL events for debugging + if event ~= "modem_message" then + -- Skip non-modem events to reduce spam + else + print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━") + print("📻 MODEM MESSAGE DETECTED!") + print(" Event: " .. event) + print(" Side: " .. tostring(side)) + print(" Channel: " .. channel) + print(" Reply channel: " .. replyChannel) + print(" Message type: " .. type(message)) + print(" CHANNEL_RECEIVE value: " .. CHANNEL_RECEIVE) + + if type(message) == "table" then + print(" Message contents:") + for k, v in pairs(message) do + print(" " .. k .. " = " .. tostring(v)) + end + end + print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━") + if channel == CHANNEL_RECEIVE then + print(" ✅ Channel matches CHANNEL_RECEIVE!") + -- Handle home position sync responses if type(message) == "table" then if message.type == "home_position" and message.turtleID == os.getComputerID() then @@ -1016,11 +1040,15 @@ parallel.waitForAny( end else -- Regular command processing + print(" Passing to processMessage()") processMessage(message) end else + print(" Message not a table, passing to processMessage()") processMessage(message) end + else + print(" ❌ Channel mismatch! Expected " .. CHANNEL_RECEIVE .. ", got " .. channel) end end end diff --git a/webbridge.lua b/webbridge.lua index 38d54c4..fd145d1 100644 --- a/webbridge.lua +++ b/webbridge.lua @@ -27,6 +27,12 @@ modem.open(CHANNEL_RECEIVE) modem.open(STATUS_CHANNEL) modem.open(POCKET_CHANNEL) +print("Webbridge Channel Configuration:") +print(" CHANNEL_RECEIVE: " .. CHANNEL_RECEIVE) +print(" STATUS_CHANNEL: " .. STATUS_CHANNEL) +print(" COMMAND_CHANNEL: " .. COMMAND_CHANNEL .. " (transmit only)") +print(" POCKET_CHANNEL: " .. POCKET_CHANNEL) + -- Track turtles and stats local turtles = {} local stats = { @@ -322,15 +328,22 @@ while true do target = turtleID } + print("📡 Transmitting command to Turtle #" .. turtleID) + print(" Channel: " .. COMMAND_CHANNEL) + print(" Command: " .. cmd.command) + print(" Target: " .. turtleID) + print(" Packet: " .. textutils.serialize(commandPacket)) + -- Send command multiple times for reliability for i = 1, 3 do modem.transmit(COMMAND_CHANNEL, CHANNEL_RECEIVE, commandPacket) + print(" Transmission " .. i .. "/3 sent") os.sleep(0.05) -- Small delay between retransmissions end -- Debug: show what we're sending if not hasMonitor then - print(" Sent to channel " .. COMMAND_CHANNEL .. ": target=" .. turtleID) + print(" ✅ Sent 3 times on channel " .. COMMAND_CHANNEL) end end