Jump to content




[Question] turtle.dig() return

turtle api help

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

#1 Ditto8353

  • New Members
  • 138 posts

Posted 15 October 2012 - 05:34 PM

Sorry for the simple question, but I am at work and have no way to test for the answer.

When turtle.dig() is successful, but the block cannot be picked up, does it return true or false?
The documentation is unclear.

#2 GopherAtl

  • Members
  • 888 posts

Posted 15 October 2012 - 05:36 PM

It returns true if a block broke, regardless of drops.

#3 Ditto8353

  • New Members
  • 138 posts

Posted 15 October 2012 - 05:43 PM

View PostGopherAtl, on 15 October 2012 - 05:36 PM, said:

It returns true if a block broke, regardless of drops.

Thank you kindly, good sir.

#4 Wutdaflux

  • New Members
  • 3 posts
  • LocationNorth Little Rock, AR

Posted 14 January 2013 - 06:30 AM

I've tried that in coding for turtles when they hit bedrock to come back, but I kept getting the "attempt to call a nil" error. I assumed after numerous failures that "if turtle.dig() == true" doesn't work. Should I true "if turtle.dig(true)" or something along those lines instead? I'm not sure that would work either. Anyway, the documentation I've read states the bool return is "success", not "true".

Any help would be appreciated.

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 14 January 2013 - 11:54 AM

View PostDitto8353, on 15 October 2012 - 05:34 PM, said:

Sorry for the simple question, but I am at work and have no way to test for the answer.

When turtle.dig() is successful, but the block cannot be picked up, does it return true or false?
The documentation is unclear.

View PostGopherAtl, on 15 October 2012 - 05:36 PM, said:

It returns true if a block broke, regardless of drops.
As GopheraAtl said it will return true regardless, but fi you wanted to tell if it dropped or not you could check the counts of the slots before digging, and then check the count after digging, to see if the block was dropped or not...


View PostWutdaflux, on 14 January 2013 - 06:30 AM, said:

I've tried that in coding for turtles when they hit bedrock to come back, but I kept getting the "attempt to call a nil" error. I assumed after numerous failures that "if turtle.dig() == true" doesn't work. Should I true "if turtle.dig(true)" or something along those lines instead? I'm not sure that would work either. Anyway, the documentation I've read states the bool return is "success", not "true".

Any help would be appreciated.
This should be in its own topic, not someone else's...
But a quick answer...
if turtle.dig() then
should work, its the same as doing
if turtle.dig() == true then
if it doesn't work then chances are its another problem, like trying to run a turtle program on a computer ( the computer can move, so it doesn't know about the turtle api, it sees any turtle function as nil )





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users