Posted 21 July 2013 - 08:02 AM
Title: Dynamically updating the functions that parallel.waitForAny uses.
Hi. I'm writing a program which uses parallel.waitForAny to sit and wait for a rednet message from a server. Generally this message will contain a set of parameters for a task which the turtle passes to a function of it's own. For example, a set of coordinates for mining. By default I just use:
However when the other function is called I need the turtle to still be able to listen and respond to rednet messages. Is there any way to dynamically add another function so the end result of the parallel command is something like:
I thought about having a string of the parallel command I need to run but I couldn't get that to work. It seems like it would run the command, but the turtle would be unresponsive. For the record the code I tried to use to get that to work was:
Hi. I'm writing a program which uses parallel.waitForAny to sit and wait for a rednet message from a server. Generally this message will contain a set of parameters for a task which the turtle passes to a function of it's own. For example, a set of coordinates for mining. By default I just use:
parallel.waitForAny(receive)
However when the other function is called I need the turtle to still be able to listen and respond to rednet messages. Is there any way to dynamically add another function so the end result of the parallel command is something like:
parallel.waitForAny(receive, parseCommand(command,param))
I thought about having a string of the parallel command I need to run but I couldn't get that to work. It seems like it would run the command, but the turtle would be unresponsive. For the record the code I tried to use to get that to work was:
local parallelCommand = "parallel.waitForAny(recieve)"
...
assert(loadstring(parallelCommand))()