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

Placing Every 10 Blocks

Started by rileysplan, 24 July 2014 - 12:49 AM
rileysplan #1
Posted 24 July 2014 - 02:49 AM
I am trying to make a mining program that tunnels down and then mines forward. My newest addition tries to place a torch every 10 blocks. Instead of placing a torch every 10 blocks it tries to place a torch in the same block 100 times.

Here's the Code:
  • term.clear()
  • term.setCursorPos(1,1)
  • for i=1, 55 do
  • turtle.digDown()
  • turtle.down()
  • – while not turtle.placeDown(15) do turtle.forward()
  • –end
  • while not turtle.forward() do turtle.dig()
  • print("Gravel!")
  • end
  • while not turtle.placeDown(15) do turtle.digDown()
  • print("No Floor!")
  • end
  • turtle.digUp()
  • for i=1, 14 do
  • turtle.select(i)
  • if turtle.compareTo(16) then
  • turtle.dropDown()
  • end
  • end
  • for i=1, 12 do
  • turtle.select(i)
  • if turtle.compareTo(13) then
  • turtle.dropDown()
  • end
  • end
  • for i = 10, 55 do
  • turtle.turnRight()
  • turtle.dig()
  • turtle.place(12)
  • turtle.turnLeft()
  • end
  • end
  • for i=1, 100 do
  • turtle.dig()
  • turtle.forward()
  • turtle.digUp()
  • for i=1, 15 do
  • turtle.select(i)
  • if turtle.compareTo(16) then
  • turtle.dropDown()
  • end
  • end
  • –Tries to Place Torch
  • for i=10, 100 do
  • turtle.turnRight()
  • turtle.dig()
  • turtle.placeRight(13)
  • turtle.turnLeft()
  • end
  • end
Bomb Bloke #2
Posted 24 July 2014 - 03:22 AM
Start out by reading the turtle API spec. Some of the functions you're calling don't take parameters. Some of the functions you're calling don't exist at all.

You need to think about your order of operations. It's no good to tell the turtle to place a torch, then place a torch, then place a torch, etc… You need to perform one torch placement for every few other actions.

Eg:

torchcounter = 0

for i=1,50 do
  move turtle forward

  torchcounter = torchcounter + 1

  if torchcounter = 10 then
     place torch
     torchcounter = 0
  end
end
hilburn #3
Posted 24 July 2014 - 07:13 AM
Another possibility, fuel? or more to the point, did you remember it>