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

Charcoal causes excavate to not come back all the way

Started by SoundChaos, 19 August 2015 - 11:12 AM
SoundChaos #1
Posted 19 August 2015 - 01:12 PM
I have tried mining turtles with the default excavate, my own modified excavate, and other peoples modified excavates, in tekkit 1.2.9e-1.2.10c (latter using computercraft 1.63), and they all have the problem where if I excavate a large area, say 15+, the turtle often does not come back all the way when I use charcoal, vs it works every time with normal coal. It often runs out of fuel completely about 1-5 blocks before it hits the origin spot, and that halts the program until manual command intervention (aka, just putting more charcoal in it doesnt start it back up automatically)

Looking at the code, it should compensate for any fuel, not just coal, but I guess it must not be getting correct fuel readings when using charcoal. This has been an issue for a long time on every computer and version of computercraft I've tried. Does anyone have any insight as to why this happens or possible modification
Lyqyd #2
Posted 19 August 2015 - 06:34 PM
Moved to Ask a Pro pending confirmation of an actual bug in ComputerCraft.
Cranium #3
Posted 19 August 2015 - 09:50 PM
This used to be an issue, but an update to the excavate program should have fixed it. There was only a rare case where the turtle would not calculate expected return fuel demands properly, and would fail to return all the way. The bug can occur in any instance of size, assuming the improper amount of fuel is provided.

One decent workaround is to try to overfuel your turtle, either to the limit defined in the config, or sending it down with an excess of surplus fuel.

In every case I've tried, the amount of fuel you get from any item has not changed, and the same amount of fuel is returned between charcoal and coal.
Bomb Bloke #4
Posted 20 August 2015 - 02:35 AM
It's possible this has something to do with the fuel caps introduced in CC 1.6. The way Dan implemented it, turtle.refuel() will continue to consume items - returning true as it does so - even if they aren't actually raising the fuel level anymore.

The excavate script consumes fuel items one at a time, and stops as soon as it figures out that it's got enough juice to travel the intended distance (assuming it knows the distance it wants to travel - that info isn't always available). This should make it incredibly unlikely that it'll "waste" fuel points by refueling past the cap.

The refuel script, on the other hand, is much more careless: it consumes stacks at a time, so if you're approaching your fuel limit and run "refuel all", odds are it'll end up wasting multiple fuel items.

That said, more info is needed to say what's really going on. Links to the exact code tested would be a good start.
SoundChaos #5
Posted 20 August 2015 - 03:31 AM
I compared the excavate script from the latest Computercraft mod files to the one in my 1.64, and found that under the
 function refuel(amount) 
the line
local needed = ammount or (xPos + zPos + depth + 2)

has a + 2 instead of + 1 like in 1.64. I changed that in a custom script and it seems to do the trick, ive yet to have it fail again

It is still bizarre to me that it only used to fail with charcoal though. I suppose it's possible that its just coincidence, since I usually do start one with coal and move to charcoal afterward.
Edited on 20 August 2015 - 01:33 AM