Advertisement
Gellis12

Logger

Apr 7th, 2014
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. print("Attempting to get position via GPS")
  2. local x, y, z = gps.locate(5)
  3. if x == nil then
  4.  print("Unable to determine position using GPS, using 0 for default height")
  5.  y = 0
  6. else
  7.  y = math.floor(y)
  8.  print("Height is ",y,", adjusting movements for GPS")
  9.  end
  10. minHeight = y
  11.  
  12. for i=1,2 do
  13.  turtle.dig()
  14.  turtle.forward()
  15. end
  16.  
  17. while turtle.detectUp() do
  18.  turtle.dig()
  19.  turtle.digUp()
  20.  if (turtle.up()) then
  21.   y = (y + 1)
  22.  else
  23.   turtle.attackUp()
  24.  end
  25. end
  26.  
  27. turtle.dig()
  28. turtle.turnRight()
  29. turtle.dig()
  30. turtle.forward()
  31. turtle.turnLeft()
  32.  
  33. while (y > minHeight) do
  34.  turtle.dig()
  35.  turtle.digDown()
  36.  if (turtle.down()) then
  37.   y = (y - 1)
  38.  else
  39.   turtle.attackDown()
  40.  end
  41. end
  42. x, y, z = gps.locate(5)
  43. if y == nil then
  44.  y = 0
  45. end
  46. y = math.floor(y)
  47. while (y > minHeight) do
  48.  turtle.attackDown()
  49.  turtle.digDown()
  50.  turtle.attack()
  51.  turtle.dig()
  52.  turtle.down()
  53.  x, y, z = gps.locate(5)
  54.  y = math.floor(y)
  55. end
  56. turtle.dig()
  57.  
  58. -- Plant new 2x2 tree
  59.  
  60. turtle.place()
  61. turtle.turnRight()
  62. turtle.back()
  63. turtle.place()
  64. turtle.turnLeft()
  65. turtle.place()
  66. turtle.back()
  67. turtle.place()
  68. turtle.back()
  69.  
  70. -- Move items into chest
  71.  
  72. for i=1,2 do
  73.  turtle.turnLeft()
  74. end
  75.  
  76. for i=2,16 do
  77.  turtle.select(i)
  78.  turtle.drop()
  79. end
  80. turtle.select(1)
  81.  
  82. for i=1,2 do
  83.  turtle.turnRight()
  84. end
  85.  
  86. print("Tree chopped!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement