Posted 30 August 2012 - 12:30 AM
The program, shown below, never stops, despite i reaching 10.
Note: the receiving turtle is inactive, so no message is received by the code, and x is not pressed.
Note: the receiving turtle is inactive, so no message is received by the code, and x is not pressed.
term.clear()
term.setCursorPos(1,1)
exit = false
exitrpt = false
i = 0
turtlecontrol = {
send = function()
repeat
i = i + 1
rednet.broadcast("intro")
print(i)
until exitrpt or i == 10
end;
receive = function()
eventtype,p1,p2,p3 = os.pullEvent()
exitrpt = true
if eventtype == "rednet_message" then
print(p2)
else
if eventtype == "char" and p1 == "x" then
exit = true
end
end
end;
}
print("Sending...")
parallel.waitForAny(turtlecontrol.send(),turtlecontrol.receive())
if exit == false then
if exitrpt == false then
print("Failed")
end
end
The full output is:And the program doesn't end.Sending…
1
2
3
4
5
6
7
8
9
10