Jump to content




Quarry Program


  • You cannot reply to this topic
1 reply to this topic

#1 grand_mind1

  • Members
  • 207 posts

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

#2 ChunLing

  • Members
  • 2,027 posts

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users