ComputerCraft Version Information: 1.46

Description of Bug:

The excavate program does not always reserve enough fuel to get back to the starting point. It sometimes gets one block away from home and runs out of fuel. This means that you can't simply add more fuel to its inventory and have it resume mining since the program won't check for fuel again unless it gets all the way home.

I believe this is caused by the following calculation in excavate's refuel function:

[indent=1]local needed = ammount or (xPos + zPos + depth + 1)[/indent]

The '+1' accounts for the fuel needed to perform the next action (such as forward()), but does not account for the fact that after performing this action, the fuel needed to get home may have increased by one (since the action may move the turtle one step further from home).

I think that changing the '+1' to '+2' fixes everything.

Steps to Reproduce Bug:

Use excavate with relatively low fuel levels and this bug should occur before too long.