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

Turtle forever miner?

Started by jakemg, 30 April 2013 - 05:13 PM
jakemg #1
Posted 30 April 2013 - 07:13 PM
Hey I just through together a test program that is just a turtle that mines forever made it set to

While not turtle.getItemCount(16) == 0 do
Dig()
End

But I think this is very sloppy because it messes up my empty function so is their a better way to do this??? Ohh and I also have it so when it get a full inventory it comes back "home" and empties its inventory but the problem with this is that it doesn't remember where it stopped mining so it mines air all the way back to where it left off so is there a way for it to save its place and go straight to where it left off and not mine their?
menz #2
Posted 30 April 2013 - 09:55 PM
Its very hard to diagnose a problem without seeing the code your trying to run. however, the answer to your second question is easy. simply add a varible that keeps track of how many moves forward youve done.

then use that varible to return to the chest and back.
jakemg #3
Posted 30 April 2013 - 09:57 PM
Well im using a distance variable but how do i get it to go back to where it started mining
Zero_Burn #4
Posted 30 April 2013 - 09:59 PM
Well, I think you don't need the "not" in the while statement.

Assume that slot 16 is empty (and that you want it to mine until there is an item in slot 16)

while not turtle.getItemCount(16) == 0

since turtle.getItemCount(16) == resolves to true we sub that in:

while not (true)

so for not, we reverse the following bool:

while (false)

so your statement would resolve to false as long as there wasn't an item in your slot 16. To have it resolve to true (e.g. keep mining until 16 has something in it), simply remove the not and you're good.

If I misunderstood, I apologize.
menz #5
Posted 30 April 2013 - 10:02 PM
everytime you run your dig function add 1 to the number in the example below i call this var numForward

use this to travel back and forth

for i = 1, numForward do
   while not turtle.forward() do end --simple loop to make sure we move
end
you can use this code as a function and use it both directions, since your not updating the number unless you run dig

*edit, keep in mind that code is extremly simplified and will sit there and try to move, until it can. as for your other problem, i cant help you without seeing your code your trying to run.