Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Credit Flaghacker
- --[[Settings]]--
- --Items
- -- the minimal amount of diffrent itemStacks
- local minStacks = 8
- -- the minimal amount of items per itemStack
- local minItems = 16
- --Bioreactor
- -- the peripheral itype for a bioreactor
- local bioReactorType = "bioreactor"
- -- (optionally) the side of the bioreactor
- local bioReactorSide
- --Chest
- -- the peripheral type for a chest
- local chestType = "chest"
- -- (optionally) the side of the chest
- local chestSide
- --[[Variables]]--
- --bioreactor peripheral
- local bioreactor
- local chest
- --[[Util]]--
- local function findPeripheralSide(peripheralType)
- for _, side in rs.getSides() do
- if peripheral.getType(side) == peripheralType then
- return side
- end
- end
- end
- --[[Functions]]--
- local function findPeripherals()
- if bioReactorSide == nil then
- bioReactorSide = findPeripheralSide(bioReactorType)
- if bioreactor == nil then
- error("No bioreactor could be found", 0)
- end
- else
- if not peripheral.getType(bioReactorSide) == bioReactorType then
- error(string.format("Peripheral on side %s is not a bioreactor.", bioReactorSide))
- end
- end
- bioreactor = peripheral.wrap(bioReactorSide)
- if chestSide == nil then
- chestSide = findPeripheralSide(chestType)
- if chestSide == nil then
- error("No chest could be found", 0)
- end
- else
- if not peripheral.getType(chestSide) == chestType then
- error(string.format("Peripheral on side %s is not a chest.", chestSide))
- end
- end
- chest = peripheral.wrap(chestSide)
- end
- --returns isFilled, slotArray
- local function checkChest()
- local slotArray = {}
- for slot, 1, chest.getInventorySize() do
- stack = chest.getStackInSlot(slot)
- if not stack == nil then
- if stack.qty > minItems then
- slotArray.add(slot)
- end
- end
- end
- if table.getn(slotArray) >= minStacks then
- return true, slotArray
- end
- return false, {}
- end
- --[[Main program]]--
- findPeripherals()
- --test
- while true do
- local bool, slots = checkChest;
- print(bool)
- print(textutils.serialize(slots)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment