Posted 02 December 2013 - 08:03 PM
I have two computers set up that are communicating with each other.
But I want the one computer to wait for the other after it sends a message to see if a message is sent back (basically checking if the other computer is on)
This is my Code : Computer 1
========================
local modem = peripheral.wrap("right")
text = io.read()
modem.transmit(35,30,text)
========================
–Ok so the modem sends a message to Computer 2
This is my Code : Computer 2
========================
local modem = peripheral.wrap("top")
modem.open(35)
local event,modemSide,senderChannel,replyChannel,message,senderDistance = os.pullEvent("modem_message")
modem.transmit(30,35,"On")
========================
–So after computer 2 receives a message it replies saying its on then Computer 1 must listen for 5 seconds then stop(so if computer 2 is offline it will not receive a message and the program on computer 1 will continue)
This is my Code(Happens right after Computer 1 transmits) : Computer 1
========================
modem.open(30)
local test,modemSide,senderChannel,replyChannel,message,senderDistance = os.pullEvent("modem_message")
if message == "On" then
print("Computer 2 is on")
end
========================
I need to use the computer 1 if there is no reply from Computer 2 . Currently it is waiting forever , is there some way I can make Computer 1 only wait 5 seconds after sending a message and if no message is received it will continue the program ?
Thanks in advance!
But I want the one computer to wait for the other after it sends a message to see if a message is sent back (basically checking if the other computer is on)
This is my Code : Computer 1
========================
local modem = peripheral.wrap("right")
text = io.read()
modem.transmit(35,30,text)
========================
–Ok so the modem sends a message to Computer 2
This is my Code : Computer 2
========================
local modem = peripheral.wrap("top")
modem.open(35)
local event,modemSide,senderChannel,replyChannel,message,senderDistance = os.pullEvent("modem_message")
modem.transmit(30,35,"On")
========================
–So after computer 2 receives a message it replies saying its on then Computer 1 must listen for 5 seconds then stop(so if computer 2 is offline it will not receive a message and the program on computer 1 will continue)
This is my Code(Happens right after Computer 1 transmits) : Computer 1
========================
modem.open(30)
local test,modemSide,senderChannel,replyChannel,message,senderDistance = os.pullEvent("modem_message")
if message == "On" then
print("Computer 2 is on")
end
========================
I need to use the computer 1 if there is no reply from Computer 2 . Currently it is waiting forever , is there some way I can make Computer 1 only wait 5 seconds after sending a message and if no message is received it will continue the program ?
Thanks in advance!