This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Danny's profile picture

Trigger an Event when a Correct Message is Sent?

Started by Danny, 23 July 2014 - 04:11 AM
Danny #1
Posted 23 July 2014 - 06:11 AM
So, I was trying to trigger an even (in this case,
print("Correct")
and
print(rec)
) but for some reason it triggers that the message isn't correct even when I broadcast the correct message. Can someone help me out? Thanks.


rednet.open("left)
rec = rednet.receive()
if rec == "Test" then
print("Correct")
print(rec)
else
print("Incorrect")
print(rec)
end

Thanks in advance!

EDIT: I took a look at the output and I found out that the computer had just sent it's own ID? I used the following in the Lua console:
rednet.broadcast("Test")
Edited on 23 July 2014 - 04:14 AM
theoriginalbit #2
Posted 23 July 2014 - 06:23 AM
Take a look at the wiki page for rednet.receive, you'll notice what it returns.
Danny #3
Posted 23 July 2014 - 06:30 AM
Take a look at the wiki page for rednet.receive, you'll notice what it returns.

Oh, that makes sense now. Thank you!