From a74332567eed385bfe08635cda8429253e3a45f6 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Wed, 24 Jun 2026 18:39:25 +0900 Subject: [PATCH] . --- PHI-CL/control.lua | 2 ++ PHI-CL/control/chest.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 PHI-CL/control/chest.lua diff --git a/PHI-CL/control.lua b/PHI-CL/control.lua index cbafd94..8281896 100644 --- a/PHI-CL/control.lua +++ b/PHI-CL/control.lua @@ -1,4 +1,5 @@ local cargo_landing = require('control/cargo-landing') +local chest = require('control/chest') local inserter = require('control/inserter') local pump = require('control/pump') local rail_support = require('control/rail-support') @@ -6,6 +7,7 @@ local trash = require('control/trash') local function entity_build(event) cargo_landing.build(event) + chest.build(event) rail_support.build(event) trash.build(event) end diff --git a/PHI-CL/control/chest.lua b/PHI-CL/control/chest.lua new file mode 100644 index 0000000..5be6d22 --- /dev/null +++ b/PHI-CL/control/chest.lua @@ -0,0 +1,31 @@ +local main = {} + +function main.build(event) + if event.entity.type ~= 'logistic-container' then + return + end + + if event.entity.logistic_mode ~= 'storage' then + return + end + + if not event.entity.has_items_inside() then + return + end + + local inventory = event.entity.get_inventory(defines.inventory.chest) + + if not inventory then + return + end + + local contents = inventory.get_contents() + + if not contents or #contents ~= 1 then + return + end + + event.entity.storage_filter = {name = contents[1].name, quality = contents[1].quality} +end + +return main