Advertisement
Guest User

tap

a guest
Nov 11th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 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.place()
  66.     turtle.dig()
  67.     turtle.digDown()
  68.     turtle.down()
  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.   print("Getting bone meal")
  89.   turtle.turnLeft() turtle.turnLeft()
  90.   turtle.forward() turtle.forward() turtle.forward()
  91.   turtle.select(3)
  92.   turtle.suck(48)
  93.   turtle.turnLeft() turtle.turnLeft()
  94.   turtle.forward() turtle.forward() turtle.forward()
  95. end
  96.  
  97. function getCoal()
  98.   print("Getting coal")
  99.   turtle.turnLeft()
  100.   turtle.forward() turtle.forward()
  101.   turtle.turnLeft()
  102.   turtle.forward() turtle.forward() turtle.forward()
  103.   turtle.select(1)
  104.   turtle.suck(48)
  105.   turtle.turnLeft() turtle.turnLeft()
  106.   turtle.forward() turtle.forward() turtle.forward()
  107.   turtle.turnRight()
  108.   turtle.forward() turtle.forward()
  109.   turtle.turnLeft()
  110. end
  111.  
  112. function restock()
  113.   if turtle.getItemCount(1) < 4 then
  114.     getCoal()
  115.   end
  116.   if turtle.getItemCount(3) < 16 then
  117.     getBoneMeal()
  118.   end
  119. end
  120.  
  121. function refuel()
  122.   if turtle.getFuelLevel() < 50 then
  123.     turtle.select(1)
  124.     turtle.refuel(4)
  125.   end
  126. end
  127.  
  128. turtle.select(6)
  129. while turtle.compareDown() do
  130.   refuel()
  131.   restock()
  132.   treeTap()
  133.   height = 0
  134.   turtle.select(6)
  135. end
  136.  
  137. print("Terminated after chopping " .. chopped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement