From b46ad62424c6f2ebde6cbfec6656b58bc2afafba Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sat, 21 Jan 2023 08:23:00 +0000 Subject: [PATCH] Send the original rednet message to the current computer We were incorrectly enquing the modem payload, not the underlying rednet message. Closes #1308. --- .../resources/data/computercraft/lua/rom/apis/rednet.lua | 2 +- src/test/resources/test-rom/spec/apis/rednet_spec.lua | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua b/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua index 23d8b3cd8..37d6aae34 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua @@ -193,7 +193,7 @@ function send(recipient, message, protocol) local sent = false if recipient == os.getComputerID() then -- Loopback to ourselves - os.queueEvent("rednet_message", os.getComputerID(), message_wrapper, protocol) + os.queueEvent("rednet_message", os.getComputerID(), message, protocol) sent = true else -- Send on all open modems, to the target and to repeaters diff --git a/src/test/resources/test-rom/spec/apis/rednet_spec.lua b/src/test/resources/test-rom/spec/apis/rednet_spec.lua index 35cb4c1df..2f57a7c08 100644 --- a/src/test/resources/test-rom/spec/apis/rednet_spec.lua +++ b/src/test/resources/test-rom/spec/apis/rednet_spec.lua @@ -37,6 +37,14 @@ describe("The rednet library", function() expect.error(rednet.send, nil):eq("bad argument #1 (expected number, got nil)") expect.error(rednet.send, 1, nil, false):eq("bad argument #3 (expected string, got boolean)") end) + + it("queues an event on the current computer", function() + rednet.send(os.getComputerID(), "Test message") + local id, message = rednet.receive(1.0) + + expect(id):eq(os.getComputerID()) + expect(message):eq("Test message") + end) end) describe("rednet.broadcast", function()