Advertisement
Guest User

Spiral Program For Mining Turtle

a guest
Dec 28th, 2012
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. function digForward(x)
  2.  for i = 1,x,1 do
  3.   if spaceInInventory() == 0 then
  4.    placeChest()
  5.   end
  6.   while(turtle.detect()) do
  7.    turtle.dig()
  8.    os.sleep(0.45)
  9.   end
  10.   turtle.forward()
  11.   while(turtle.detectUp()) do
  12.    turtle.digUp()
  13.    os.sleep(0.45)
  14.   end
  15.  end
  16. end
  17.  
  18. function spaceInInventory()
  19.  for i = 1,16,1 do
  20.   if turtle.getItemCount(i) == 0 then
  21.    return 1
  22.   end
  23.  end
  24.  return 0
  25. end
  26.  
  27. function goBack(x, numberSpirals)
  28.  turtle.turnRight()
  29.  for i=0,x/2,1 do
  30.   turtle.back()
  31.  end
  32.  turtle.turnLeft()
  33.  digForward(3*(numberSpirals/4))
  34. end
  35.  
  36. function placeChest()
  37.  refuel()  
  38.  turtle.select(2)
  39.  turtle.turnRight()
  40.  turtle.dig()
  41.  turtle.forward()
  42.  turtle.digUp()
  43.  turtle.back()
  44.  turtle.select(1)
  45.  turtle.place(1)
  46.  for i = 2 , 16 do
  47.   turtle.select(i)
  48.   turtle.drop()
  49.  end
  50.  turtle.select(1)
  51.  turtle.dig()
  52.  turtle.turnLeft()
  53. end
  54.  
  55. function refuel()
  56.  if turtle.getFuelLevel() > 5000 then
  57.   return
  58.  end
  59.  for i=2,16,1 do
  60.   turtle.select(i)
  61.   turtle.refuel(64)
  62.  end
  63. end
  64.  
  65. local arguments = {...}
  66.  
  67. x = 0
  68. for i = 1,tonumber(arguments[1]),1 do
  69.  if i % 2 == 0 then
  70.   x = x+2
  71.  else x = x+1 end
  72.  digForward(x)
  73.  turtle.turnLeft()
  74. end
  75. goBack(x, tonumber(arguments[1]))
  76. placeChest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement