Jump to content




[Lua] Rednet Message


  • You cannot reply to this topic
2 replies to this topic

#1 lieudusty

  • Members
  • 419 posts

Posted 20 July 2012 - 05:48 AM

Hi everyone! :P/>

I'm trying to make a program where if it gets the right message from another computer it will return with "Message received!".
But when I try:
rednet.open("left")
state = rednet.receive(10)
if state == "clock" then
  print("Message received!")
end
it doesn't work. Can someone please help?

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 20 July 2012 - 03:40 PM

rednet.receive returns 3 values: the id of the sender, the message and the distance from the sender. To use the message, you need to store it in a variable. You only stored the id.
Fixed code:
rednet.open("left")
local id, state = rednet.receive(10)
if state == "clock" then
  print("Message Received!")
end


#3 lieudusty

  • Members
  • 419 posts

Posted 20 July 2012 - 04:20 PM

Thank you so much! I've been confused by this for a while.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users