5 posts
Posted 24 December 2012 - 06:07 PM
So i was messing around with some code trying to replicate SethBlings fell program and found that my turtle wouldnt come back down. He gets to the top, moves over to the other side, and just stops. EDIT: it isnt a fuel issue i dont think because i had refuelled the turtle with a stack of coal.
Heres my code:
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
while turtle.detect() do
turtle.dig()
turtle.digUp()
turtle.Up()
end
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
while turtle.compareDown() do
turtle.digDown()
turtle.down()
turtle.dig()
end
2005 posts
Posted 24 December 2012 - 06:27 PM
turtle.compareDown is returning false. It looks like you dig into the trunk at the bottom, then digUp until you hit air. Then you turn right, dig forward, turn left, dig forward, and then you want to go back down.
I presume you're trying to fell a giant jungle tree with this? But you dug up through the canopy, and probably have leaves rather than trunk beneath your turtle. So of course turtle.compareDown is returning false.
Oh, to fix this you probably want to replace your earlier turtle.detect with turtle.compare, so that you stop when you reach the top of the trunk and don't keep going till you clear the canopy.
Edited on 24 December 2012 - 05:29 PM
5 posts
Posted 24 December 2012 - 06:36 PM
Ah, brilliant, thanks :)/>
15 posts
Posted 25 December 2012 - 07:31 AM
I made one of these yesterday, I think this worked.
while not turtle.detectDown() do
5 posts
Posted 25 December 2012 - 03:56 PM
Trying to use functions now, can somebody tell me why this only digs the first layer of a tree and stops?
local function start()
turtle.detect()
turtle.dig()
turtle.forward()
turtle.dig()
end
local function chopUp()
turtle.select(1)
while turtle.compareUp() do
turtle.digUp()
turtle.up()
turtle.dig()
end
end
local function moveOver()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
end
local function chopDown()
turtle.select(1)
while turtle.compareDown() do
turtle.digDown()
turtle.down()
turtle.dig()
end
end
start()
chopUp()
moveOver()
chopDown()
2005 posts
Posted 26 December 2012 - 03:04 PM
You don't select slot one before starting (since you don't select any other slot, you should just do it at the beginning and be done with it). That could allow the initial blocks to be placed somewhere else, in which case your function chopUp wouldn't do anything (except selecting slot 1). Then, since you are on the ground already, chopDown doesn't do anything either (slot 1 already being selected).