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

[Code not working] Failing in making my own tree farm

Started by Dueu800, 22 September 2012 - 01:27 AM
Dueu800 #1
Posted 22 September 2012 - 03:27 AM
I was writing my own tree farm to learn the lua code, and i came up with this


local x = 1
while x < 11 do
   turtle.place()
   turtle.select(2)
   turtle.place()
   turtle.select(1)
	  if turtle.detect() then
		 turtle.dig()
		 turtle.up()
			if turtle.detectUp() then
			   turtle.digUp()
	  if not turtle.detect() and not turtle.detectDown() then
		 turtle.down()
		 x = x+1
			end
	  end
end
what this should do:
place an sapling, then use bone meal on it, then cut the whole tree down and if there is an block blocking the turtle it will break it and when finishes cutting the it would com back down and do all that again
The problem is, the line:

if not turtle.detect() and not turtle.detectDown() then
	  turtle.down()
is not working can somebody help me?
Zoinky #2
Posted 22 September 2012 - 04:04 AM

local x = 1
while x < 11 do
   turtle.place()
   turtle.select(2)
   turtle.place()
   turtle.select(1)
   if turtle.detect() then
	 turtle.dig()
	 turtle.up()
	 elseif turtle.detectUp() then
	  turtle.digUp()
	  elseif not turtle.detect() and not turtle.detectDown() then
	   turtle.down()
	   x = x+1
	  end
	 end
   end
end

Try that! :)/>/>
Dueu800 #3
Posted 22 September 2012 - 04:10 AM

local x = 1
while x < 11 do
   turtle.place()
   turtle.select(2)
   turtle.place()
   turtle.select(1)
   if turtle.detect() then
	 turtle.dig()
	 turtle.up()
	 elseif turtle.detectUp() then
	  turtle.digUp()
	  elseif not turtle.detect() and not turtle.detectDown() then
	   turtle.down()
	   x = x+1
	  end
	 end
   end
end

Try that! :)/>/>


eof expected on line 18…
Zoinky #4
Posted 22 September 2012 - 05:42 AM
Woops. Try this:

local x = 1
while x < 11 do
turtle.place()
turtle.select(2)
turtle.place()
turtle.select(1)
if turtle.detect() then
  turtle.dig()
  turtle.up()
  elseif turtle.detectUp() then
   turtle.digUp()
   elseif not turtle.detect() and not turtle.detectDown() then
    turtle.down()
    x = x+1
end
end
sjele #5
Posted 22 September 2012 - 09:43 AM
eof expected often means you have one to many ends.