r/ComputerCraft • u/Seabass2272 • Apr 20 '24
Trying to make a 1 chunk quarry through a mining turtle and running into trouble
local x = 0
local z = 0
while true do
turtle.dig()
turtle.forward()
x = x + 1
if x == 15 then
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
x = 0
end
if x == 15 and z == 15 then
turtle.digDown()
turtle.down()
x = 0
z = 0
end
end
Right now, the turtle just spins in a circle and breaks the block in front of it. Where is it getting stuck? TIA
1
Upvotes
7
u/fatboychummy Apr 20 '24 edited Apr 20 '24
As u/Life-Ad6389 stated already, the turtle doesn't automatically refuel like a furnace. You need to run
refuel allin the shell, then it will consume the coal (or other fuel items) in its inventory and tell you how much fuel it has.This is the reason it doesn't move and just turns on the spot, at least. Your code will still have some issues that will cause it to just do big "circles" forever, since you never increment
z. Also, you want to go across the chunk in a back-and-forth pattern, so you'll need to alternate the direction in which you turn.I wrote up a tutorial on how to do this a little while back, it might help you get the rest of your code working! It starts with a pretty basic explanation of for loops, but should help you get the back-n-forth motion figured out.
1
u/Life-Ad6389 Apr 20 '24
Does it have fuel?
2
u/thegroundbelowme Apr 20 '24
your second "if" block will never be true, because as soon as x == 15 you reset it to zero before the second conditional can be evaluated.
And as someone already said, you need to increment Z.
1
u/SadieWopen Apr 21 '24
Couple of bits of feedback: learn how to use a for loop, learn how to nest for loops, don't use while true do, check fuel level periodically and refuel on demand, find a way to clear the inventory if you want to collect the useful blocks, figure out how to clear fluid like water and lava or you'll be left with cobble and obsidian behind your dig.
Learn how to use functions too, it will help you compartmentalize the logic.
1
u/[deleted] Apr 20 '24
[removed] — view removed comment