–snip–
msg = rednet.receive(ID)
if msg == "Redstone Action" then
[ACTION CODE GOES HERE]
end
I am a bit rust at rednet but pretty sure it's right
The beginning is quite correct, or well mostly, and enough for most to use. but the code that I've listed here is wrong, rednet.receive takes two arguments and your spelling is incorrect, ceive not cieve.
rednet.receive([timeout],[protocol])
That is the syntax for it, the first argument and second are both OPTIONAL, but timeout is the first, and protocol is the second.
Timeout works like this: I specify that I want a 3 timeout, it will start to listen, and if no message has come in by the end of 3 seconds, then it continues on with the code with senderID and message set to nil.
Protocol works like this: I set a rednet protocol on my send, (rednet,send has 3 arguments, id, message, and protocol) and then i set the same rednet protocol on my receive (It's just a string, can be WHATEVER you want), the receive will wait until it gets a rednet message with that protocol, any other message will be discarded.
--#Receiving computer. ID 0
local id, message = rednet.receive("my,message") --# Something I failed to mention, if you set a protocol as the first argument, it will still work
print(message)
--#Sending computer one
rednet.send(0,"Hello")
--#Sending computer two
rednet.send(0,"Hello There","my,message")
--#The receiving computer will print out:
"Hello There"
HOWEVER, all that being said, you don't HAVE to use rednet, you can use the modem API and that's what it seems like you're trying to do.
Sending computer:
local modem = peripheral.wrap("back") --# A pocket computer will have the wireless modem IN THE BACK
modem.open(61) --#Any number 1-65535
--#Technically the sending computer does NOT have to open the channel to send, but if you want confirmation, it's good to have it open.
modem.transmit(213,61,"hello")
modem.transmit's arguments are:
channel to send to
channel they can send back to you with
message
Receiving computer:
local modem = peripheral.wrap("back")
modem.open(213)
local event = {os.pullEvent("modem_message")}
print(event[5])
Modem APIThere are no protocols in the modem api, only 65535 different channels to use.