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

parallel running functions

Started by cardinal Lucius, 23 June 2014 - 10:38 AM
cardinal Lucius #1
Posted 23 June 2014 - 12:38 PM
Hello there,
This is the setting: i have a code listening for rednet messages incoming.
(like this):
Spoilerfunction RednetListener()
while true do
–print("Ready for RednetInput")
local id, message, distance = rednet.receive()
local splitMessage = Split(message, " ")
if splitMessage[1] == "pa" then
if splitMessage[2] == "setup" then
if splitMessage[3] == "locate" then
rednet.send(id, "pa setup masterHere")
worker[wtblin] = id
wtblin = wtblin + 1
print("Worker" .. wtblin .. " listed")
print("Has id " .. tonumber(worker[wtblin-1]))
end
elseif splitMessage[2] == "job" then
if splitMessage[3] == "request" then
local job = GetJobForTurtle()
print("Turtle " .. id .. " now has job " .. job)
if SendAndGetResponse(id, "pa job do " .. job) ~= "pa job confirm" then
jobNumber = jobNumber - 1
print("JobRequestReceived - but not confirmed!!!")
end
end
end
end
end
end

It is embedded in an endless loop, so you cant access the console of the computer to type in anything.
And now the question: is it possible to get input by the player with e.g. the read() commmand while the computer is performing the rednet listener?
Edited on 23 June 2014 - 11:03 AM
Bomb Bloke #2
Posted 23 June 2014 - 01:42 PM
Sure.
cardinal Lucius #3
Posted 23 June 2014 - 05:31 PM
Ahhh it really works :D/>
Thanks for the fast reply!