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

[lua]

Started by emil7370, 11 October 2012 - 05:19 PM
emil7370 #1
Posted 11 October 2012 - 07:19 PM
Hey.

I don't understand what i wrong with my code, I don't get any errors but nothing happens. It should make some redstone on the back of the computer light up, but it doesn't. it is also using a lock.

the transmitters code:

while true do
term.clear()
term.setCursorPos(1, 1)
print("Please Enter Password:")
input = read("*")
if input == "open" then
  rednet.open("left")
  rednet.send(8, "open")
  end
if input == "close" then
  rednet.open("left")
  rednet.send(9, "close")
end
end

the receivers code:

rednet.open("left")
while true do
a, b = rednet.receive()
if b == "open" then
  redstone.setOutput("back", true)
  end
if b == "close" then
  redstone.setOutput("back", false)
  end
end

Please help :P/>/>
Lyqyd #2
Posted 11 October 2012 - 07:39 PM
You are putting in "open" or "close" when it asks for the password, correct?
remiX #3
Posted 11 October 2012 - 07:57 PM
Try this. It should work. And remember: Make sure you have the ID's correct!

the transmitters code:

rednet.open("left")
while true do
  term.clear()
  term.setCursorPos(1, 1)
  print("Please Enter Password:")
  input = read("*")
  if input == "open" then
	rednet.send(8, "open")
  elseif input == "close" then
	rednet.send(9, "close")
  else
	print("Type open or close!")
	sleep(2)
  end
end

the receivers code:

rednet.open("left")
while true do
  senderId, b, distance = rednet.receive()
  if b == "open" then
	redstone.setOutput("back", true)
  elseif b == "close" then
	redstone.setOutput("back", false)
  end
end
emil7370 #4
Posted 12 October 2012 - 01:35 PM
Thanks for help.
Good someone like you are here :)/>/>
PonyKuu #5
Posted 12 October 2012 - 01:38 PM
You also sending "open" and "close" messages to different computers (ID = 8, and ID = 9)