From ead0f5ea8cada242c522b268cf29d08eeaef8bdc Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sun, 2 Sep 2018 20:57:14 +0300 Subject: [PATCH] aef --- Applications/Robot/ReactorFiller.lua | 67 +++++++++++++++++++++------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/Applications/Robot/ReactorFiller.lua b/Applications/Robot/ReactorFiller.lua index de88d26a..eabbb80a 100644 --- a/Applications/Robot/ReactorFiller.lua +++ b/Applications/Robot/ReactorFiller.lua @@ -10,8 +10,8 @@ local inventory_controller = component.inventory_controller local QUAD_FUEL = "IC2:reactorMOXQuad" local DIAM_VENT = "IC2:reactorVentDiamond" local IRON_VENT = "IC2:reactorVentSpread" -local STON_VENT = "IC2:reactorHeatSwitchSpread" -local GOLD_VENT = "IC2:reactorVent" +local STON_VENT = "IC2:reactorVent" +local GOLD_VENT = "IC2:reactorHeatSwitchSpread" local RCTR_PLAT = "IC2:reactorPlating" local allowed = { @@ -32,21 +32,56 @@ local map = { IRON_VENT, DIAM_VENT, GOLD_VENT, STON_VENT, IRON_VENT, STON_VENT, GOLD_VENT, DIAM_VENT, IRON_VENT, } -local filledMap = {} +local args = {...} -for robotSlot = 1, robot.inventorySize() do - local stack = inventory_controller.getStackInInternalSlot(robotSlot) - if stack and allowed[stack.name] then - for mapSlot = 1, #map do - if map[mapSlot] == stack.name and not filledMap[mapSlot] then - robot.select(robotSlot) - print("Drop status", inventory_controller.dropIntoSlot(sides.front, mapSlot, 1)) - filledMap[mapSlot] = true - break +if args[1] == "fill" then + print("Filling...") + + local filledMap = {} + for robotSlot = 1, robot.inventorySize() do + local stack = inventory_controller.getStackInInternalSlot(robotSlot) + if stack and allowed[stack.name] then + for mapSlot = 1, #map do + if map[mapSlot] == stack.name and not filledMap[mapSlot] then + robot.select(robotSlot) + print("Drop status", inventory_controller.dropIntoSlot(sides.front, mapSlot, 1)) + filledMap[mapSlot] = true + break + end end end - - print(serialization.serialize(stack, true)) - event.pull("key_down") end -end \ No newline at end of file +elseif args[1] == "count" then + print("Checking...") + + local need, have = {}, {} + for i = 1, #map do + need[map[i]] = (need[map[i]] or 0) + 1 + end + + for i = 1, robot.inventorySize() do + local stack = inventory_controller.getStackInInternalSlot(i) + if stack and allowed[stack.name] then + have[stack.name] = (have[stack.name] or 0) + stack.size + end + end + + for key, value in pairs(need) do + local name = key:sub(12, -1) + + if have[key] then + if have[key] < value then + print(name .. ": put " .. (value - (have[key] or 0))) + else + print(name .. ": OK, over " .. (have[key] - value)) + end + else + print(name .. ": put " .. value) + end + end +end + + + + +