-- Attach peripherals local meBridge = peripheral.find("meBridge") -- Replace 'left' with the side your ME Bridge is connected to local chest = peripheral.wrap("bottom") -- Replace 'bottom' with the side your chest is connected to local maxSeedsItemInChest = 128; -- Function to move an item to the beginning of the chest local function moveItemToFront(chest, itemName) local chestContents = chest.list() local firstSlot = 1 -- Look for the item in the chest for slot, item in pairs(chestContents) do if item.name == itemName then -- Move the item to the first available slot if chest.pushItems(peripheral.getName(chest), slot, item.count, firstSlot) > 0 then print("Moved " .. itemName .. " to slot " .. firstSlot .. " in the chest.") end return end end -- If the item is not found, do nothing end -- Function to check if an item is below the threshold in the chest local function isItemBelowThreshold(chest, itemName, threshold) local chestContents = chest.list() for _, item in pairs(chestContents) do if item.name == itemName then return item.count < threshold end end -- If the item is not found in the chest, treat it as below threshold return true end -- Function to transfer Mystical Agriculture seeds local function transferMysticalSeeds() -- Get all available items from the ME system local items = meBridge.listAvailableItems() local seedsFound = false -- Loop through items to find seeds from Mystical Agriculture for _, item in ipairs(items) do if string.find(item.name, "seed") and string.find(item.name, "mysticalagriculture") then seedsFound = true -- Check if the chest has fewer than 128 of this item if isItemBelowThreshold(chest, item.name, maxSeedsItemInChest) then -- Move existing items to the first slot moveItemToFront(chest, item.name) -- Transfer new items to the chest local toExtract = math.min(maxSeedsItemInChest, item.amount) local success = meBridge.exportItem({ name = item.name }, "bottom", toExtract) if success then print("Transferred " .. toExtract .. " of " .. item.name .. " to the chest.") else print("Failed to transfer " .. item.name .. ".") end else print(item.name .. " already has 128 or more in the chest.") end end end if not seedsFound then print("No Mystical Agriculture seeds found in the ME system.") end end -- Run the function in a loop while true do transferMysticalSeeds() print("Waiting for 1 seconds before checking again...") os.sleep(1) -- Wait for 1 seconds before checking again end