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

rednet door client and server

Started by rick3333, 27 November 2014 - 11:50 PM
rick3333 #1
Posted 28 November 2014 - 12:50 AM
i need help with a door client and server. i am using the mag strip cards from immibis peripherals

code

masterId = 3
reader = peripheral.wrap("left")

rednet.open("back")

while true do
  event, data, side = os.pullEvent("mag_swipe")
  rednet.send(3,data,143)
  sId, msg, dist = rednet.receive("143")
  term.setCursorPos(1,1)
  if data == msg then
		  redstone.setOutput("right",true)
		  sleep(5)
		  redstone.setOutput("right",false)
  end
end
Edited on 03 December 2014 - 02:51 AM
Dog #2
Posted 28 November 2014 - 01:07 AM
Hey, rick3333 - I'll start with the standard suggestions:

1. Please use code tags [.CODE] [./CODE] (without the dots) so your code is easier to read.
2. Please tell us what you expect the program to do, and what the program is actually doing.
3. Please include the full text of any error messages.

I've put your code in code tags and indented it below so it's easier to read, and I think I see one error right off the bat.


masterId = 3
reader = peripheral.wrap("left")

rednet.open("back")

while true do
  event, data, side = os.pullEvent("mag_swipe")
  rednet.send(3,data,143)
  sId, msg, dist = rednet.receive("143")
  term.setCursorPos(1,1)
  if data == msg then
    redstone.setOutput("right",true)
    sleep(5)
    redstone.setOutput("right",false)
  end
end

You aren't specifying your protocol with a string.

Change…

rednet.send(3,data,143)

to…

rednet.send(3,data,"143")
Edited on 28 November 2014 - 12:08 AM
Dragon53535 #3
Posted 28 November 2014 - 01:09 AM
It looks like you're sending the number 143 instead of a string.

rednet.send(3,data,143)
--#probably should be
rednet.send(3,data,"143")

EDIT: :ph34r:/> 'd
Edited on 28 November 2014 - 12:09 AM