3 posts
Posted 01 May 2014 - 05:28 PM
I want to write a program for making area flat with turtle. I wrote a part of them. This part have to do dig x and y coordinates. First, turtle detect forward then detects up and dig. Then turtle have to down first layer then again turtle digs forward one blok and digs up. But now turtle doesn't go down. It is going like stairs.
print("x: ")
local x = tonumber(read())
i=1
while x>=i do
y=0
if turtle.detect(true) then
turtle.dig(left)
end
turtle.forward()
i=i+1
while turtle.detectUp(true) do
turtle.digUp(left)
turtle.up()
y=y+1
end
turtle.down(y)
end
7083 posts
Location
Tasmania (AU)
Posted 02 May 2014 - 02:23 AM
These functions:
turtle.detect()
turtle.dig()
turtle.detectUp()
turtle.digUp()
turtle.down()
… don't take parameters. As in, they ignore the true / left / y stuff you're passing to them. "if turtle.detect(true) then" is effectively the same as "if turtle.detect() then".
The only spot where this appears to matter is when you run "turtle.down(y)" - "turtle.down()" always goes down once, and passing it y won't change that. Try "for j=1,y do turtle.down() end".
28 posts
Posted 02 May 2014 - 08:47 AM
If you want dig left, you have to rotate turtle. turtle.rotate(270). (I hope this function takes parametres D:)
7083 posts
Location
Tasmania (AU)
Posted 02 May 2014 - 09:31 AM
turtle.turnLeft() and turtle.turnRight() don't take parameters, and would also need to be manually looped. turtle.rotate() doesn't exist by default.
Checking the list in the
turtle API documentation, if there aren't any parameters shown for the function in the method name column, then that function will typically ignore any parameters passed to it.
28 posts
Posted 02 May 2014 - 12:02 PM
Hmmm, so i had not standard api :D/> Sry for troubles..