Jump to content


Uch1ha_Sasuke's Content

There have been 3 items by Uch1ha_Sasuke (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#154957 Rednet Checking for incoming Messages (for a certain time only)

Posted by Uch1ha_Sasuke on 03 December 2013 - 04:02 AM in Ask a Pro

Oke well i still have no idea how do do this . I can make the timer but how do i implement it into my code?
The os.pullEvent is waiting for a reply infinitely so how can there be a timer running in the same line??



#154915 Rednet Checking for incoming Messages (for a certain time only)

Posted by Uch1ha_Sasuke on 02 December 2013 - 08:03 PM in Ask a Pro

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!



#154890 If statement using OR's

Posted by Uch1ha_Sasuke on 02 December 2013 - 06:42 PM in Ask a Pro

I have an advanced computer with a wireless modem on the right.

My program :
==============================================================================

rednet.open("right")
local modem = peripheral.wrap("right")
text = io.read()

==============================================================================
Then it needs to check if the input was a "1" or "2" or "3" or "4" using a if statement i am using this which does not work :
==============================================================================

if text ~= "1" or "2" or "3" or "4" then
print("Incorrect Data")
end

==============================================================================

Need some help figuring this out
Thank You in advance!