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

I need help about turtle program

Started by quelamia, 01 May 2014 - 03:28 PM
quelamia #1
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
Bomb Bloke #2
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".
OczkoSX #3
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:)
Bomb Bloke #4
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.
OczkoSX #5
Posted 02 May 2014 - 12:02 PM
Hmmm, so i had not standard api :D/> Sry for troubles..