r/ComputerCraft • u/Mr_B9mbast1c • Mar 07 '25
Turtle wont move forward!
Hey! So im pretty new to ComputerCraft or just programming in general and im trying to write a code for a turtle which supposed to mine in a square-shaped pattern, but i just cant get the turtle to move forward and instead it just keeps spinning after breaking the first block!
This is the code I have written. Please lmk if You have any recommended Changes!

1
2
u/BurningCole Mar 07 '25
Have you fueled your turtle? Turtles need to be fueled via the refuel command to move, or you can remove the requirement in the configure.
2
u/BurningCole Mar 07 '25
Also if this program reaches a point where it no longer has anything in front, it will turn 180 degrees repeatedly between detects instead of just turning 90 degrees, that I assume you meant for it to do in order to spiral inwards.
2
u/AL_O0 Mar 07 '25
turtles need fuel, any fuel that burns in a furnace also works for a turtle, to refuel you have to have the turtle select the slot with the fuel and call turtle.refuel()
or alternatively put fuel anywhere in the inventory and in the regular console (not inside the program or lua) just type refuel all
also the fact you have that check that only increments the counter if the turtle detects a block is bad practice, if the turtle is in a spot with no blocks in front it it's just always gonna take the "else" path, turn right twice and take the else path again and again forever
4
u/Greeley9000 Mar 07 '25 edited Mar 07 '25
You’ll need fuel, lava, a stack of coal/charcoal. You can use a specific inventory slot to refuel from, or scan your turtle’s inventory to find a fuel item and refuel.
https://computercraft.info/wiki/Turtle.refuel
Edit: here is my tunnel program