Advertisement
Greenlamp

test

Feb 23rd, 2025 (edited)
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. local function refuel()
  2.   local level = turtle.getFuelLevel()
  3.   if level < 25 then
  4.     turtle.select(1)
  5.     turtle.refuel(2)
  6.   end
  7. end
  8.  
  9. local function isLog()
  10.     s, data = turtle.inspect()
  11.     ret = data.name == "minecraft:spruce_log"
  12.     print(data.name)
  13.     print(ret)
  14.     return ret
  15. end
  16.  
  17. local function isEmpty()
  18.     s, data = turtle.inspect()
  19.     return data.name == nil
  20. end
  21.  
  22. local function restock()
  23.     turtle.select(2)
  24.     local count = turtle.getItemCount(2)
  25.     if (count < 12) then
  26.         turtle.turnLeft()
  27.         turtle.suck(8)
  28.         turtle.turnRight()
  29.     end
  30.     turtle.select(1)
  31. end
  32.  
  33. local function plant()
  34.     refuel()
  35.     restock()
  36.     turtle.forward()
  37.     turtle.select(2)
  38.     turtle.place()
  39.     turtle.turnRight()
  40.     turtle.forward()
  41.     turtle.turnLeft()
  42.     turtle.place()
  43.     turtle.back()
  44.     turtle.place()
  45.     turtle.turnLeft()
  46.     turtle.forward()
  47.     turtle.turnRight()
  48.     turtle.place()
  49.     turtle.select(1)
  50. end
  51.  
  52. local function flushItems()
  53.     count = turtle.getItemCount(4)
  54.     if count > 0 then
  55.         turtle.turnLeft()
  56.         turtle.turnLeft()
  57.         for cnt=3, 16, 1 do
  58.             turtle.select(cnt)
  59.             turtle.drop()
  60.         end
  61.         turtle.turnLeft()
  62.         turtle.turnLeft()
  63.         turtle.select(1)
  64.     end
  65. end
  66.  
  67. local function chop()
  68.     turtle.dig()
  69.     turtle.digUp()
  70. end
  71.  
  72. local function chopDown()
  73.     turtle.dig()
  74.     local s, blockDown = turtle.inspectDown()
  75.     print(blockDown.name)
  76.     if blockDown.name == "minecraft:spruce_log" then
  77.         turtle.digDown()
  78.     end
  79. end
  80.  
  81. local function changeRow()
  82.     turtle.turnRight()
  83.     turtle.dig()
  84.     turtle.forward()
  85.     turtle.turnLeft()
  86. end
  87.  
  88. local function resetPos()
  89.     turtle.back()
  90.     turtle.turnLeft()
  91.     turtle.forward()
  92.     turtle.turnRight()
  93. end
  94.  
  95. while true do
  96.     os.sleep(2)
  97.     flushItems()
  98.     if isEmpty() then
  99.         plant()
  100.     end
  101.     if isLog() then
  102.         turtle.dig()
  103.         turtle.forward()
  104.         while isLog() do
  105.             refuel()
  106.             chop()
  107.             turtle.up()
  108.         end
  109.         changeRow()
  110.         while isLog() do
  111.             refuel()
  112.             chopDown()
  113.             turtle.down()
  114.         end
  115.         resetPos()
  116.     end
  117. end
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement