hhhzzzsss

charcoalblocks.lua

Aug 23rd, 2023 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. local craftSlots = {1, 2, 3, 5, 6, 7, 9, 10, 11}
  2. local nonCraftSlots = {4, 8, 12, 13, 14, 15, 16}
  3.  
  4. local function getChestItemCount()
  5.     local inputChest = peripheral.wrap("bottom")
  6.     if peripheral.hasType("bottom", "inventory") then
  7.         local inputChest = peripheral.wrap("bottom")
  8.         local items = inputChest.list()
  9.         if not items then
  10.             return 0
  11.         end
  12.         local itemCount = 0
  13.         for _, detail in pairs(items) do
  14.             itemCount = itemCount + detail.count
  15.         end
  16.         return itemCount
  17.     else
  18.         return 0
  19.     end
  20. end
  21.  
  22. while true do
  23.     if getChestItemCount() > 4*9*64 then
  24.         failed = false
  25.         for _, i in ipairs(craftSlots) do
  26.             if turtle.getItemCount(i) < 64 then
  27.                 turtle.select(i)
  28.                 turtle.suckDown(64-turtle.getItemCount())
  29.             end
  30.             if turtle.getItemCount(i) == 0 then
  31.                 failed = true
  32.             end
  33.         end
  34.         for _, i in ipairs(nonCraftSlots) do
  35.             if turtle.getItemCount(i) > 0 then
  36.                 turtle.dropDown()
  37.             end
  38.         end
  39.  
  40.         if not failed then
  41.             turtle.craft()
  42.             for i=1, 16 do
  43.                 detail = turtle.getItemDetail(i)
  44.                 if detail and detail.name == "betterend:charcoal_block" then
  45.                     turtle.select(i)
  46.                     turtle.drop()
  47.                 end
  48.             end
  49.         end
  50.     else
  51.         sleep(10)
  52.     end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment