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

Receiver (No Message?)

Started by Jman, 31 July 2013 - 07:46 PM
Jman #1
Posted 31 July 2013 - 09:46 PM
Okay so My receiver for my door mechanism has been acting up ever since I made it and now that I have written a new program for both of my Senders it doesn't even want to pretend that a message is there. NO MATTER WHAT THE MESSAGE IS! Like What The Heck! At first it was just not setting any value at all to my bundled cable beneath it so I started playing around with the code on the receiver. Then adjusting the code on my primary sender so that I can send a test message, to the receiver in hope that my receiver just had a bad line of code but instead after the ninth edit it doesn't want to do anything but the first two print commands inside the code. if someone thinks they can help me out then here's the code for the receiver, and the messages have to be flexible because both messages come from both of my Senders (1 - Primary) and (2 - Secondary). Both Senders are just as important it's just that one comes before the other.
--FUNCTIONS
function checkMessage()
  if message == "OPEN" then
	g = colors.combine( g, colors.orange, colors.magenta)
	rs.setBundledOutput("bottom", g)
	g = colors.subtract(g, colors.white)
	rs.setBundledOutput("bottom", g)
	print("open")
  elseif message == "CLOSE" then
	c = colors.subtract( c, colors.orange, colors.magenta)
	rs.setBundledOutput( "bottom", c)
	c = colors.combine( c, colors.white)
	rs.setBundledOutput( "bottom", c)
	print("close")
  end
end

--CODE
rednet.open("back")
d = 1
while true do
  term.clear()
  term.setCursorPos(1,1)
  print("Cycle - "..d)
  print("Phase - 1")
  message = rednet.receive()
  checkMessage()
  print("Phase - 2")
  message = rednet.receive()
  checkMessage()
  print("Phase - 3")
  d = d + 1
end
P.S. - I'm using CC 1.4.7
Tiin57 #2
Posted 31 July 2013 - 10:06 PM
Don't use the rednet API; it's been deprecated. Instead, use os.pullEvent('rednet_message'). (Or something like that)
Jman #3
Posted 31 July 2013 - 10:17 PM
nope didn't work, still being super stubborn for me. and my dang cable wont set the output I have dead cables all through out the process
Jman #4
Posted 31 July 2013 - 10:21 PM
I've noticed with my own project that you won't even get a "rednet_message" event from os.pullEvent even when using the rednet API to send. It will still show up as a "modem_message" event. I know that with the gps API, the rednet communication comes through on channel 65534, so it might be worth it for the OP to revise the script to use the modem API from top to bottom and cut out some of the guess work.
Ok and huh?