local component = require("component") local robot = require("robot") local sides = require("sides") local inventory = component.inventory_controller; local function contains(arr, val) for _, value in ipairs(arr) do if value == val then return true end end return false end local function store_stack(slot) robot.select(slot) local slots = inventory.getInventorySize(sides.forward) for s = 1, slots do local result, _ = inventory.dropIntoSlot(sides.forward, s) if result then local stack = inventory.getStackInInternalSlot(slot) if stack == nil then break end end end end local function store(whitelist) local slots = robot.inventorySize() for slot = 2, slots do local item = inventory.getStackInInternalSlot(slot) if item then if whitelist ~= nil then if contains(whitelist, item.name) then store_stack(slot) end else store_stack(slot) end end end end return { store = store, }