This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xmd's profile picture

[1.5] os.queueEvent("modem_message", ...) also fires rednet_message

Started by xmd, 17 February 2013 - 05:33 PM
xmd #1
Posted 17 February 2013 - 06:33 PM
Hi,

the following snippet illustrates the issue clearly:


local function showModemMessageProblem()
	os.queueEvent("modem_message", "back", 155, 125, "foo")
	print(os.pullEvent())
	print(os.pullEvent())
end
showModemMessageProblem()

Queueing of modem_message implicitly generates a rednet_message, i guess this is a fix for backwards compatibility.

I have code which buffers events it doesn't care about at the time to re-queue them later on, which leads to lots and lots of duplicated rednet_messages because of this.

I don't know if you consider this a bug, but to me, this is unexpected behaviour which shouldn't happen, imho the right way would be to generate both events at the source once.
Cloudy #2
Posted 17 February 2013 - 10:00 PM
People complained we removed rednet_message so we added a task to queue it when a modem_message is received. This is intended.
xmd #3
Posted 18 February 2013 - 04:51 AM
I thought so, but couldn't you just queue rednet_message whenever a "real" modem_message is queued, wherever that happens?

To me, the current way of addressing this problem feels dirty (even though i know several ways around the problems it caused for me).
LBPHacker #4
Posted 18 February 2013 - 04:58 AM
rednet_message is fired by the rednet API, overwrite it if you don't like it.

If you don't want rednet to fire rednet_message events, you can easily disable it by changing this
local ok, err = pcall( function()
parallel.waitForAny( 
function()
os.run( {}, "rom/programs/shell" )
end,
function()
rednet.run()
end )
end )
to this
local ok, err = pcall( os.run, {}, "rom/programs/shell" )
in bios.lua.

This way you can still use the modems.
Eric #5
Posted 25 February 2013 - 07:38 AM
You should never have to requeue events - use the parallel API instead, where all events are sent to each thread.