Advertisement
Guest User

tap

a guest
Nov 11th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. height = 0
  2. chopped = 0
  3. function grow()
  4.   print("Growing")
  5.   turtle.select(2)
  6.   turtle.place()
  7.   turtle.select(4)
  8.   while not turtle.compare() do
  9.     turtle.select(3)
  10.     turtle.place()
  11.     turtle.select(4)
  12.   end
  13. end
  14.  
  15. function adjust()
  16.   print("Adjusting")
  17.   turtle.turnRight()
  18.   turtle.dig()
  19.   turtle.forward()
  20.   turtle.turnLeft()
  21.   turtle.dig()
  22.   turtle.forward()
  23.   turtle.turnLeft()
  24. end  
  25.  
  26. function tapUp1()
  27.   print("Tapping up 1")
  28.   turtle.select(4)
  29.   while turtle.compare() do
  30.     turtle.select(5)
  31.     turtle.place()
  32.     turtle.digUp()
  33.     turtle.up()
  34.     turtle.select(4)
  35.     height = height + 1
  36.   end
  37.   print("Height " .. height)
  38.   turtle.dig()
  39. end
  40.  
  41. function tapUp2()
  42.   print("Tapping up 2")
  43.   turtle.select(5)
  44.   for i=2,height do
  45.     turtle.place()
  46.     turtle.digUp()
  47.     turtle.up()
  48.   end
  49. end
  50.  
  51. function tapDown1()
  52.   print("Tapping down 1")
  53.   turtle.select(5)
  54.   for i=1,height do
  55.     turtle.digDown()
  56.     turtle.down()
  57.     turtle.place()
  58.   end
  59. end
  60.  
  61. function tapDown2()
  62.   print("Tapping down 2")
  63.   turtle.select(5)
  64.   for i=2,height do
  65.     turtle.digDown()
  66.     turtle.down()
  67.     turtle.place()
  68.     turtle.dig()
  69.   end
  70. end  
  71.  
  72. function treeTap()
  73.   grow()
  74.   tapUp1()
  75.   adjust()
  76.   tapDown1()
  77.   adjust()
  78.   tapUp2()
  79.   adjust()
  80.   tapDown2()
  81.   adjust()
  82.  
  83.   chopped = chopped + 1
  84.   print("Chopped " .. chopped)
  85. end
  86.  
  87. function getBoneMeal()
  88.   turtle.turnLeft() turtle.turnLeft()
  89.   turtle.forward() turtle.forward() turtle.forward()
  90.   turtle.select(3)
  91.   turtle.suck(48)
  92.   turtle.turnLeft() turtle.turnLeft()
  93.   turtle.forward() turtle.forward() turtle.forward()
  94. end
  95.  
  96. function getCoal()
  97.   turtle.turnLeft()
  98.   turtle.forward() turtle.forward()
  99.   turtle.turnLeft()
  100.   turtle.forward() turtle.forward() turtle.forward()
  101.   turtle.select(1)
  102.   turtle.suck(48)
  103.   turtle.turnLeft() turtle.turnLeft()
  104.   turtle.forward() turtle.forward() turtle.forward()
  105.   turtle.turnRight()
  106.   turtle.forward() turtle.forward()
  107.   turtle.turnLeft()
  108. end
  109.  
  110. function restock()
  111.   if turtle.getItemCount(1) < 4 then
  112.     getCoal()
  113.   end
  114.   if turtle.getItemCount(3) < 16 then
  115.     getBoneMeal()
  116.   end
  117. end
  118.  
  119. function refuel()
  120.   if turtle.getFuelLevel() < 50 then
  121.     turtle.select(1)
  122.     turtle.refuel(4)
  123.   end
  124. end
  125.  
  126. turtle.select(6)
  127. while turtle.compareDown() do
  128.   refuel()
  129.   restock()
  130.   treeTap()
  131.   height = 0
  132.   turtle.select(6)
  133. end
  134.  
  135. print("Terminated after chopping " .. chopped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement