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

Secret Turtle Door Problem

Started by applesauce10189, 18 January 2014 - 08:33 PM
applesauce10189 #1
Posted 18 January 2014 - 09:33 PM
I have a slight problem, I have a couple turtles and a computer. All three are wireless. The computer is giving out commands just fine. The first turtle I set up is working fine. The second one just sits there. I'll give the code to all three programs. Just to save space I'll put them in spoilers.


Not working turtle.
Spoiler

rednet.open("right")
  while true do
	id, message = rednet.receive()
	if message == "on" then
	  turtle.dig()
	  turtle.forward()
	  turtle.digDown()
	  turtle.back()
	  sleep(3)
	  turtle.forward()
	  turtle.placeDown()
	  turtle.back()
	  turtle.place()
   elseif turtle.getFuelLevel() <= 50 then
	  turtle.dig()
	  for i = 1, 2 do
		turtle.forward()
	  end
	  turtle.select(2)
	  turtle.placeDown()
	  turtle.suckDown()
	  turtle.digDown()
	  turtle.select(1)
	  for i = 1, 2 do
		turtle.back()
	  end
      turtle.place()
   end
end
Computer.
Spoiler

rednet.open("back")
while true do
term.clear()
term.setCursorPos(1,1)
term.setTextColor(1024)
print("AppleOS v1")
term.setTextColor(1)
print("Welcome to Apple's secret computercraft room!")
print("I need proof you are Apple or someone he trusts.")
print("Please insert password.")
term.setCursorPos(1,5)
while true do
  local x = read("*")
  if x == "derp" then
	rednet.send(116, "open")
	break
  elseif x == "griefer" then
	rednet.send(120, "open")
	break
  else
	term.clear()
	term.setCursorPos(1,1)
	print("WRONG!")
	sleep(2.5)
	os.reboot()
  end
end
end
Working turtle.
Spoiler

term.clear()
term.setCursorPos(1,1)
print("AppleOS V1")
term.setTextColor(1)
term.write("Thank you for choosing")
term.write(" AppleOS")
term.write(".")
term.setCursorPos(1,3)
fuel = turtle.getFuelLevel()
print("Fuel level: "..fuel)
rednet.open("right")
while true do
id, message = rednet.receive(1)
if message == "open" or rs.getInput("back") == true then
  turtle.forward()
  turtle.turnLeft()
  turtle.dig()
  turtle.up()
  turtle.dig()
  turtle.down()
  turtle.turnRight()
  turtle.back()
  sleep(5)
  turtle.forward()
  turtle.turnLeft()
  turtle.place()
  turtle.up()
  turtle.place()
  turtle.down()
  turtle.turnRight()
  turtle.back()
  os.reboot()
end
end
if turtle.getFuelLevel() <= 50 then
  turtle.select(2)
  turtle.forward()
  turtle.placeUp()
  turtle.suckUp()
  turtle.digUp()
  turtle.back()
  turtle.select(1)
end

EDIT: Checked and double checked turtle ID's. That isn't what's wrong.
ANOTHER EDIT: Fixed a small problem. Not related to this post.
Edited on 18 January 2014 - 08:39 PM
OReezy #2
Posted 18 January 2014 - 09:49 PM
In the non working turtle, you compare the message to "on" instead of "open"

 if message == "on" then
applesauce10189 #3
Posted 18 January 2014 - 09:50 PM
In the non working turtle, you compare the message to "on" instead of "open"

 if message == "on" then
Thank you very much :)/>