Advertisement
agentsix1

Untitled

Jun 6th, 2023 (edited)
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 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:birch_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:birch_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.forward()
  83.         for i = 1, 10 do   
  84.             turtle.digUp()
  85.             turtle.up()
  86.         end
  87.         for i = 1, 10 do   
  88.             turtle.digDown()
  89.             turtle.down()
  90.         end
  91.         turtle.back()
  92.         turtle.select(3)
  93.         turtle.place()
  94.     else
  95.         if isSap() then
  96.         else
  97.             turtle.select(3)
  98.             turtle.place()
  99.         end
  100.     end
  101.     turtle.turnRight()
  102. end
  103.  
  104. function check()
  105.     for i = 1, 5 do
  106.         fuelCheck()
  107.         for i = 1, 10 do
  108.             mF()
  109.         end
  110.         turtle.turnRight()
  111.         mF()
  112.         turtle.turnRight()
  113.        
  114.         for i = 1, 5 do
  115.             chop()
  116.             mF()
  117.             mF()
  118.         end
  119.         mF()
  120.         turtle.turnLeft()
  121.         mF()
  122.         mF()
  123.         turtle.turnLeft()
  124.         mF()
  125.     end
  126. end
  127.  
  128. function restart()
  129.     turtle.turnLeft()
  130.     for i = 1, 15 do
  131.         turtle.attack()
  132.         turtle.forward()
  133.     end
  134.     dropItems()
  135. end
  136.  
  137. function dropItems()
  138.     turtle.turnLeft()
  139.     for i = 1, 16 do
  140.         if i > 3 then
  141.             if turtle.getItemCount(i) > 0 then
  142.                 turtle.select(i)
  143.                 turtle.drop()
  144.             end
  145.         end
  146.     end
  147.     turtle.turnRight()
  148.     turtle.turnRight()
  149. end
  150.  
  151. local chopping = true
  152. while chopping do
  153.     check()
  154.     restart()
  155. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement