Advertisement
hornedcommando

Minecraft Turtle Furnace Manager

Apr 21st, 2024
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.64 KB | Gaming | 0 0
  1. --Work in Progress
  2. --TODO: Load Cookables in top
  3. --TODO: Extract Finished product, return to chest
  4. --TODO: Determine how many furnaces this little guy can manage and have him setup that many instead of just 1
  5. --A turtle furnace Management Program
  6. --by hornedcommando
  7.  
  8. function input()
  9.     while true do
  10.         write("I need a furnace, and a chest to work properly, Ok?")
  11.          break
  12.     end
  13. end
  14.  
  15. -- Function to search the inventory for an item from a table
  16. function searchInventory(items)
  17.     print("Searching inventory for items")
  18.     for slot = 1, 16 do
  19.         turtle.select(slot)
  20.         local slotDetail = turtle.getItemDetail()
  21.         if slotDetail then
  22.             for _, item in ipairs(items) do
  23.                 if slotDetail.name == item then
  24.                     print("Found " .. item .. " in slot " .. slot)
  25.                     return true, slot
  26.                 end
  27.             end
  28.         end
  29.     end
  30.     print("Could not find any items in inventory")
  31.     return false
  32. end
  33.  
  34. function setup()
  35.     print("setting up")
  36.     searchInventory("minecraft:furnace")
  37.     turtle.place()
  38.     turtle.turnRight()
  39.     turtle.forward()
  40.     turtle.turnLeft()
  41.     searchInventory("minecraft:chest")
  42.     turtle.place()
  43.     turtle.up()
  44.     turtle.forward()
  45.     turtle.forward()
  46.     turtle.down()
  47.     turtle.turnLeft()
  48.     turtle.turnLeft()
  49. end
  50.  
  51. -- Function to wait until items are put into a chest
  52. function waitForItems()
  53.     print("Waiting for items...")
  54.     local pulledSomething = false
  55.     while not inventoryFull() do
  56.         if turtle.suck() then
  57.             pulledSomething = true
  58.         else
  59.             if pulledSomething then
  60.                 print("No more items in the chest")
  61.                 break
  62.             end
  63.         end
  64.         sleep(1)  -- Adjust the sleep duration as needed
  65.     end
  66. end
  67.  
  68. local fuels = {
  69.     "minecraft:coal",
  70.     "minecraft:charcoal",
  71.     "minecraft:oak_planks",
  72.     "minecraft:stick",
  73.     "minecraft:wooden_pickaxe",
  74.     "minecraft:wooden_shovel",
  75.     "minecraft:wooden_axe",
  76.     "minecraft:wooden_sword",
  77.     "minecraft:oak_slab",
  78.     "minecraft:oak_sapling",
  79.     "minecraft:spruce_sapling",
  80.     "minecraft:birch_sapling",
  81.     "minecraft:jungle_sapling",
  82.     "minecraft:acacia_sapling",
  83.     "minecraft:dark_oak_sapling",
  84.     "minecraft:bamboo",
  85.     "minecraft:kelp",
  86.     "minecraft:lava_bucket",
  87.     "minecraft:blaze_rod",
  88.     "minecraft:coal_block",
  89.     "minecraft:dried_kelp_block",
  90. }
  91.  
  92. function fuelFurnace()
  93.     turtle.turnRight()
  94.     turtle.forward()
  95.     turtle.turnLeft()
  96.     turtle.drop()
  97. end
  98.  
  99.  
  100. setup()
  101. waitForItems()
  102. searchInventory(fuels)
  103. fuelFurnace()
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement