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

[Question] turtle.dig() return

Started by Ditto8353, 15 October 2012 - 04:34 PM
Ditto8353 #1
Posted 15 October 2012 - 06: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.
GopherAtl #2
Posted 15 October 2012 - 06:36 PM
It returns true if a block broke, regardless of drops.
Ditto8353 #3
Posted 15 October 2012 - 06:43 PM
It returns true if a block broke, regardless of drops.

Thank you kindly, good sir.
Wutdaflux #4
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.
theoriginalbit #5
Posted 14 January 2013 - 11:54 AM
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.
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…


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 )