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

Rednet receive and send at the same time

Started by jonassvensson4, 10 March 2016 - 05:51 PM
jonassvensson4 #1
Posted 10 March 2016 - 06:51 PM
I wonder if it is possible to receive a message and send one at the same time?

I want it to send the data ALL THE TIME to the monitor, But it gets stuck at the receive. Any workaround without having two computers?

Reactor program:
http://pastebin.com/K6B8FCrK
TYKUHN2 #2
Posted 10 March 2016 - 08:05 PM
Technically not possible because of how Computercraft (and probably LuaJ) works, but doing something along the lines of the parallel API would probably suit your needs (also make sure you need what you think you need, you probably can have slower updates but I don't know what you need)
Edited on 10 March 2016 - 07:05 PM
Lyqyd #3
Posted 10 March 2016 - 08:46 PM
No, it's perfectly possible to do what's actually being asked about. You'd want to structure your program to use an event handling loop. You'd use a timer event (or key/char events, or whatever generates the data to send) to determine when to send rednet messages, and you'd handle incoming rednet_message events in the same loop.
TYKUHN2 #4
Posted 11 March 2016 - 07:53 PM
I added technically referring to the nature of blocking in ComputerCraft, while recognizing that, giving a minuscule downtime that is more than likely impactless, it is still possible to do as requested.
Lyqyd #5
Posted 11 March 2016 - 10:16 PM
There's no meaningful "downtime" anyway. You have to yield regardless, so the code already has no way to consume 100% of the server's CPU time. And yes, updating once per second will be more than sufficient for reactor stats displays.