19 posts
Posted 24 January 2013 - 05:47 PM
So I am writing a program for a turtle tree farm and I want my turtle to dig up until turtle.detectUp() == false
this is what i am thinking:
function uptill()
while turtle.detectUp() == true do
turtle.digUp()
turtle.up()
until turtle.detectUp() == false
--[ at which point i want it to come back down until turtle.detectDown == true ]--
3790 posts
Location
Lincoln, Nebraska
Posted 24 January 2013 - 05:52 PM
local height = 0
while turtle.detectUp() do
turtle.digUp()
turtle.up()
height = height + 1
end
repeat
turtle.down()
height = height - 1
until height == 0
That should work for you!
7508 posts
Location
Australia
Posted 24 January 2013 - 05:57 PM
local height = 0
while turtle.detectUp() do
turtle.digUp()
turtle.up()
height = height + 1
end
repeat
turtle.down()
height = height - 1
until height == 0
That should work for you!
why not just this since a tree can only grow on a block
while turtle.detectUp() do
turtle.digUp()
turtle.up()
end
while turtle.down()
end
3790 posts
Location
Lincoln, Nebraska
Posted 24 January 2013 - 06:01 PM
That may be true, but I always like to count how far I have traveled. It helps me figure out where I can add in additional code, such as detecting more leaves, or other things. Just a personal preference.
19 posts
Posted 24 January 2013 - 06:04 PM
local height = 0
while turtle.detectUp() do
turtle.digUp()
turtle.up()
height = height + 1
end
repeat
turtle.down()
height = height - 1
until height == 0
That should work for you!
Thanks :D/> That counting how far up then going down that many was a good idea! Never would have thought of it ;)/>