Jump to content




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


  • You cannot reply to this topic
4 replies to this topic

#1 xmd

  • Members
  • 5 posts

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.

#2 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

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.

#3 xmd

  • Members
  • 5 posts

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).

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

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.

#5 Eric

  • Members
  • 92 posts
  • LocationUK

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users