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

Quarry Program

Started by grand_mind1, 01 February 2013 - 02:30 PM
grand_mind1 #1
Posted 01 February 2013 - 03:30 PM
I started working on a new turtle quarry program, but I am having a problem with it. I want the user to be able to type in how deep they want the quarry to be however I can't seem to get it to stop once it gets to that depth. This is what I have:

local tArgs = { ... }
local depth = 0
local maxdepth = tArgs[1]
local fuel = turtle.getFuelLevel()
local function qry()
  turtle.digDown()
  turtle.down()
  turtle.dig()
  turtle.turnLeft()
  turtle.dig()
  turtle.turnLeft()
  turtle.dig()
  turtle.turnLeft()
  turtle.dig()
  turtle.turnLeft() 
end
local function dropoff()
  for i = 1, 16 do
    turtle.select(i)
    turtle.dropUp()
    i = i+1
  end
end

term.clear()
term.setCursorPos(1,1)
print("I will try to go down ",maxdepth," blocks")
print(maxdepth)
while depth ~= maxdepth do
  qry()
  depth = depth+1
  print(depth)
end
for i = 1, depth do
  turtle.up()
end
dropoff()
When I run the program it just keeps going after reaching the specified depth. Some of the things in the program are my debug attempts.
Help is appreciated!
Thanks! :D/>
ChunLing #2
Posted 01 February 2013 - 05:06 PM
maxdepth is a string, because you never tonumber it. Thus it is never equal to depth, which is always a number.