33 posts
Posted 27 May 2015 - 01:54 AM
I noticed that messages sent by rednet are received under the "rednet_message" event, while not-rednet messages are "modem_message". How is the event type decided? Is it by the sender or receiver? can I send a message as a totally different event (ex: "bluenet_message")? Any answer is appreciated!
7083 posts
Location
Tasmania (AU)
Posted 27 May 2015 - 02:02 AM
When you send a rednet message, it's always sent as a "modem message".
When a computer reaches the end of its boot process, it starts two bits of code (running side by side, using the
parallel API) - shell (or multishell), and
rednet.run().
Whenever the code running through shell yields (in order to pull an event), rednet.run() gets a chance to look at the event queue for modem_message events. If it finds one which it determines was originally sent via rednet.send(), it generates a rednet_message event using
os.queueEvent(), which
your code (running through the shell coroutine) is able to pull (via eg rednet.receive()).
By modifying shell or the rednet API via a resource pack, you can indeed use the same technique to generate eg "bluenet_message" events.
33 posts
Posted 28 May 2015 - 06:09 AM
Thanks for the fast reply!