Posted 09 October 2012 - 06:58 PM
So i have this program that works with rednet and i have it so that whenever i send a signal from pc A to pc B eg. "a" it will read for the signal on pc B and if it is "a" it will start a loop. Now my problem is that in this loop i want it to run the loop and then check for a signal eg. "b". If it doesn't get a signal it will keep running the loop but if it gets "b" it will stop the loop and go back to waiting for "a".
Here are the programs so you know what i am talking about.
The sending program:
The receiving program:
The loop i am talking about is the clock() function.
Here are the programs so you know what i am talking about.
The sending program:
rednet.open("left")
while true do
term.clear()
term.setCursorPos(1,1)
write("Input: ")
write("")
input = read()
if input == "a" then
rednet.send(1,"1")
elseif input == "b" then
rednet.send(1,"2")
elseif input == "c" then
rednet.send(1,"3")
end
end
The receiving program:
rednet.open("left")
local function clock()
print("1")
os.sleep(.2)
print("2")
os.sleep(.2)
rednet.receive(.2)
if msg == "" then
clock()
elseif msg == "2" then
end
end
while true do
term.clear()
term.setCursorPos(1,1)
print("Waiting")
local evt, id, msg = os.pullEvent("rednet_message")
if msg == "1" then
clock()
elseif msg == "2" then
print("LOL NOPE")
os.sleep(.5)
end
end
The loop i am talking about is the clock() function.