agentsix1

Tree Feller CC v0.0.4

Jun 17th, 2019
32,765
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. function fuelCheck()
  2.     local fuelLevel = turtle.getFuelLevel()
  3.     if turtle.getItemCount(1) < 1 then
  4.         print("We are currently waiting to be refueled!")
  5.         local waiting = true
  6.         while waiting do
  7.             if turtle.getItemCount(1) > 0 then
  8.                 print("Thank you!")
  9.                 waiting = false
  10.                 sleep(1)
  11.             end
  12.         end
  13.     end
  14.     if fuelLevel < 100 then
  15.         turtle.select(1)
  16.         turtle.refuel(2)
  17.         print("Refueled.")
  18.     end
  19. end
  20.  
  21. function isLog()
  22.     local success, data = turtle.inspect()
  23.     if data.name == "minecraft:log" then
  24.         return true
  25.     else
  26.         return false
  27.     end
  28. end
  29.  
  30. function isSap()
  31.     local success, data = turtle.inspect()
  32.     if data.name == "minecraft:sapling" then
  33.         return true
  34.     else
  35.         return false
  36.     end
  37. end
  38.    
  39.  function plantTree()
  40.     turtle.turnLeft()
  41.     turtle.select(3)
  42.     turtle.place()
  43.     turtle.turnRight()
  44.     turtle.select(1)
  45. end
  46.  
  47.  function clean()
  48.     turtle.suckUp()
  49.     turtle.suck()
  50.     turtle.turnLeft()
  51.     turtle.suck()
  52.     turtle.turnLeft()
  53.     turtle.suck()
  54.     turtle.turnLeft()
  55.     turtle.suck()
  56.     turtle.turnLeft()
  57.     turtle.suck()
  58. end
  59.  
  60. function mF()
  61.     clean()
  62.     turtle.attack()
  63.     turtle.forward()
  64. end
  65.  
  66. function mB()
  67.     clean()
  68.     turtle.turnLeft()
  69.     turtle.turnLeft()
  70.     clean()
  71.     turtle.attack()
  72.     turtle.forward()
  73.     clean()
  74.     turtle.turnLeft()
  75.     turtle.turnLeft()
  76. end
  77.  
  78. function chop()
  79.     turtle.turnLeft()
  80.     if isLog() then
  81.         turtle.dig()
  82.         turtle.select(3)
  83.         turtle.place()
  84.     else
  85.         if isSap() then
  86.         else
  87.             turtle.select(3)
  88.             turtle.place()
  89.         end
  90.     end
  91.     turtle.turnRight()
  92. end
  93.  
  94. function check()
  95.     for i = 1, 5 do
  96.         fuelCheck()
  97.         for i = 1, 10 do
  98.             mF()
  99.         end
  100.         turtle.turnRight()
  101.         mF()
  102.         turtle.turnRight()
  103.        
  104.         for i = 1, 5 do
  105.             chop()
  106.             mF()
  107.             mF()
  108.         end
  109.         mF()
  110.         turtle.turnLeft()
  111.         mF()
  112.         mF()
  113.         turtle.turnLeft()
  114.         mF()
  115.     end
  116. end
  117.  
  118. function restart()
  119.     turtle.turnLeft()
  120.     for i = 1, 15 do
  121.         turtle.attack()
  122.         turtle.forward()
  123.     end
  124.     dropItems()
  125. end
  126.  
  127. function dropItems()
  128.     turtle.turnLeft()
  129.     for i = 1, 16 do
  130.         if i > 3 then
  131.             if turtle.getItemCount(i) > 0 then
  132.                 turtle.select(i)
  133.                 turtle.drop()
  134.             end
  135.         end
  136.     end
  137.     turtle.turnRight()
  138.     turtle.turnRight()
  139. end
  140.  
  141. local chopping = true
  142. while chopping do
  143.     check()
  144.     restart()
  145. end
Add Comment
Please, Sign In to add comment