Posted 29 December 2012 - 05:04 PM
Hello,
to learn how to do more in Lua i've set myself the task of making a simple mesaging system using Rednet.
So far i've got the modem setup and username creation parts sorted but i'm completely stuck on actually sending and receiving the messages.
I need the computer to both wait for new messages coming in from rednet.receive() and wait for new messages to be sent out with read() but i can't seem to find a way to get them both running at the same time.
I'm trying to use the Parallel API but when i try it the system just starts the first function (either send or receive) and then pauses as the function waits for either a rednet message or user input and then alternates to the other function once it gets a response.
http://pastebin.com/BgUT2Q5K
How can i fix my code so that it lets you type new messages to be sent whilst waiting for incoming messages to print?
Thanks
to learn how to do more in Lua i've set myself the task of making a simple mesaging system using Rednet.
So far i've got the modem setup and username creation parts sorted but i'm completely stuck on actually sending and receiving the messages.
I need the computer to both wait for new messages coming in from rednet.receive() and wait for new messages to be sent out with read() but i can't seem to find a way to get them both running at the same time.
I'm trying to use the Parallel API but when i try it the system just starts the first function (either send or receive) and then pauses as the function waits for either a rednet message or user input and then alternates to the other function once it gets a response.
http://pastebin.com/BgUT2Q5K
How can i fix my code so that it lets you type new messages to be sent whilst waiting for incoming messages to print?
Thanks