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

Turtle Program Not Working in 1.4 Update

Started by doodlebug95, 08 January 2013 - 04:22 PM
doodlebug95 #1
Posted 08 January 2013 - 05:22 PM
I created my first real program for a mining turtle (back when they had 9 slots)

Now when I run it in the 1.4 update (turtles have 16 slots) it just spins in a circle

Whats wrong?


function dig()
  turtle.turnLeft()
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.up()
  turtle.digUp()
  turtle.up()
  turtle.turnRight()
  turtle.turnRight()
  turtle.dig()
  turtle.forward()
  turtle.digDown()
  turtle.dig()
  turtle.forward()
  turtle.digDown()
  turtle.down()
  turtle.digDown()
  turtle.down()
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
end
function moveForward()
  turtle.select(2)
  turtle.dig()
  turtle.forward()
  if turtle.detectDown() == false then
  turtle.placeDown()
  end
end
function placeTorch()
  turtle.select(1)
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.place()
  turtle.turnRight()
  turtle.turnRight()
end
term.clear()
term.setCursorPos(1, 1)
print("How Far Should I Dig?")
numberToMine = tonumber(read())
counter = 0
torchCounter = 0
textutils.slowPrint("Please Put 20 Torches in My Top Left Slot")
while turtle.getItemCount(1) < 20 do
	sleep(5)
print("Please Insert " .. 20 - turtle.getItemCount(1) .. " more torches")
end
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Now Tunneling")

while counter < numberToMine do
  if torchCounter == 10 then
	placeTorch()
torchCounter = 0
  end
  moveForward()
  dig()
  counter = counter + 1
  torchCounter = torchCounter + 1
end
print("Mined Tunnel " .. numberToMine .. " Block(s) Long")
Dlcruz129 #2
Posted 08 January 2013 - 05:23 PM
Turtles need fuel to move. Put coal in the current slot and type 'refuel', or call turtle.refuel()
theoriginalbit #3
Posted 08 January 2013 - 05:38 PM
and if you opt for the code way add a function into the code that uses
turtle.getFuelLevel()
which returns the number of blocks the turtle can move. also notable is if the turtle cannot move, it can be; 1. Block in its way ( use turtle.dig() ), 2. Mob in its way ( use turtle.attack() ) or 3. out of fuel ( write a fuel checking function )
doodlebug95 #4
Posted 09 January 2013 - 03:21 PM
Thanks guys I can't believe I missed that