Jump to content




I need help about turtle program


  • You cannot reply to this topic
4 replies to this topic

#1 quelamia

  • Members
  • 3 posts

Posted 01 May 2014 - 04: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.

Quote

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


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 02 May 2014 - 01: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".

#3 OczkoSX

  • Members
  • 29 posts

Posted 02 May 2014 - 07:47 AM

If you want dig left, you have to rotate turtle. turtle.rotate(270). (I hope this function takes parametres D:)

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 02 May 2014 - 08: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.

#5 OczkoSX

  • Members
  • 29 posts

Posted 02 May 2014 - 11:02 AM

Hmmm, so i had not standard api :D Sry for troubles..





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users