Advertisement
DYankee

chest check test

Jun 23rd, 2021 (edited)
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. function checkAge()
  2.     isBlock, data = turtle.inspect()
  3.     if (data['state']['age'] == 7)
  4.     then
  5.         isgrown = true
  6.     elseif (data['state']['age'] ~= 7)
  7.     then
  8.         isgrown = false
  9.     end
  10. end
  11.  
  12. function waitForGrowth()
  13.     checkAge()
  14.     while isgrown == false do
  15.         sleep(5)
  16.         checkAge()
  17.     end
  18. end
  19.  
  20. function getFuelIndex()
  21.     for slotNum = 1, 16, 1 do
  22.       local Item = turtle.getItemDetail(slotNum)
  23.       if(Item ~=nil) then
  24.         if(Item["name"] == "minecraft:coal_block" or Item["name"] == "actuallyadditions:block_misc" or Item["name"] == "quark:charcoal_block") then
  25.           return slotNum
  26.         end
  27.       end
  28.     end
  29. end
  30.  
  31. function refuel()
  32.     if(turtle.getFuelLevel() < 400) then
  33.     Index = getFuelIndex()
  34.       if(Index ~= nil) then
  35.       turtle.select(Index)
  36.       turtle.refuel(2)
  37.       end
  38.     end
  39. end
  40.  
  41. function getCarrotIndex()
  42.     for slotNum = 1, 16, 1 do
  43.         local item = turtle.getItemDetail(slotNum)
  44.         if(item ~=nil) then
  45.             if(item["name"] == "minecraft:carrot") then
  46.                 return slotNum
  47.             end
  48.         end
  49.     end
  50. end
  51.  
  52. function harvest()
  53.     turtle.dig()
  54.     turtle.suck()
  55.     index = getCarrotIndex()
  56.     turtle.select(index)
  57.     turtle.place()
  58.     local carrotNum = turtle.getItemCount() - 1
  59.     turtle.dropDown(carrotNum)
  60. end
  61.  
  62. function goLeft()
  63.     turtle.turnLeft()
  64.     local isBlock = turtle.detect()
  65.     if isBlock == true then
  66.         state, tags = turtle.inspect()
  67.             if (tags.name == "quark:oak_chest") then
  68.                 getFuelIndex()
  69.                 local coalBlocks = turtle.getItemCount()
  70.                 if coalBlocks <= 4 then
  71.                     turtle.suck(30)
  72.                     turtle.turnLeft()
  73.                     waitForGrowth()
  74.                     harvest()
  75.                 end
  76.         elseif (tags.name ~= "quark:oak_chest") == false then
  77.             turtle.forward()
  78.             turtle.turnRight()
  79.             end
  80.     elseif isBlock ~= true then
  81.         turtle.forward()
  82.         turtle.turnRight()
  83.         end
  84. end
  85.  
  86.  
  87. while true do
  88.     goLeft()
  89.     harvest()
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement