Advertisement
mahldcat

darkmatter.lua

Jul 17th, 2024 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. -- Define the input and output peripherals
  2. local inputChest = peripheral.wrap("minecraft:chest_1")
  3. local outputAltar = peripheral.wrap("summoningrituals:altar_1")
  4.  
  5. -- Define the list of required items
  6. local requiredItems = {
  7. "minecraft:netherite_scrap",
  8. "allthemodium:allthemodium_ingot",
  9. "alltheores:enderium_ingot",
  10. "megacells:sky_steel_ingot",
  11. "projecte:aeternalis_fuel_block"
  12. }
  13.  
  14. -- Function to check for required items in the input chest
  15. local function checkForRequiredItems()
  16. local itemsFound = {}
  17. local items = inputChest.list()
  18.  
  19. for _, requiredItem in ipairs(requiredItems) do
  20. itemsFound[requiredItem] = false
  21. end
  22.  
  23. for slot, item in pairs(items) do
  24. if itemsFound[item.name] == false then
  25. itemsFound[item.name] = { slot = slot, count = item.count }
  26. end
  27. end
  28.  
  29. for _, requiredItem in ipairs(requiredItems) do
  30. if itemsFound[requiredItem] == false then
  31. print("Missing item: " .. requiredItem)
  32. return nil
  33. end
  34. end
  35.  
  36. return itemsFound
  37. end
  38.  
  39. -- Function to transfer items from the input chest to the output altar
  40. local function transferItems(itemsFound)
  41. for _, requiredItem in ipairs(requiredItems) do
  42. local itemInfo = itemsFound[requiredItem]
  43. if itemInfo and itemInfo.count > 0 then
  44. inputChest.pushItems(peripheral.getName(outputAltar), itemInfo.slot, 1)
  45. print("Transferred one " .. requiredItem .. " to the altar")
  46. end
  47. end
  48. end
  49.  
  50. -- Main function
  51. local function main()
  52. local itemsFound = checkForRequiredItems()
  53. if not itemsFound then
  54. print("Aborting: Not all required items are present in the chest.")
  55. return
  56. end
  57. transferItems(itemsFound)
  58. print("All required items have been transferred to the altar.")
  59. end
  60.  
  61. -- Run the main function
  62. main()
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement