82 posts
Posted 02 January 2013 - 06:25 PM
I want to have a turtle always be open for a certain signal, waiting for it, though still be ready for normal tasks. Normally, it just has the normal command line, though, you can not type / assign programs. Is there anyway to have a program "running in the background" still waiting to receive a message while being able to perform the tasks you want it to?
2088 posts
Location
South Africa
Posted 02 January 2013 - 07:53 PM
Yes, take a look at the
parallel API
function listen()
while true do
senderid, message = rednet.receive()
print(message)
end
end
function OtherFunctions()
--Code
end
--More code!
parallel.waitForAny(listen, OtherFunctions) -- waitForAny will stop if any of the functions return,
parallel.waitForAll(listen, OtherFunctions) -- waitForAll will stop only when all functions have returned
82 posts
Posted 03 January 2013 - 07:39 AM
@remiX Though do you know if there is a way instead of using it to run multiple functions in a single program, use the default OS whilest a program is running, without you interacting with it? (That of which is still waiting for an rednet input)
2088 posts
Location
South Africa
Posted 03 January 2013 - 08:04 AM
Default OS? Are you talking about the shell with "> " and you can type in programs?
82 posts
Posted 03 January 2013 - 10:05 AM
Yes
2088 posts
Location
South Africa
Posted 03 January 2013 - 10:31 AM
The only way I can think of is if you make your own shell within the program where you can open programs and such