From 5f09d999b4a492f7a94335a19f5bd36f5d9d1d2d Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Wed, 1 Jul 2026 22:22:41 +0900 Subject: [PATCH] . --- PHI-CL/control.lua | 19 ++----------------- PHI-CL/control/inserter.lua | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/PHI-CL/control.lua b/PHI-CL/control.lua index b9651b4..f452d23 100644 --- a/PHI-CL/control.lua +++ b/PHI-CL/control.lua @@ -30,26 +30,11 @@ local function gui_create(player) end end - do - local frame = player.gui.relative.add({type = 'frame', name = 'phi_cl_inserter', anchor = {gui = defines.relative_gui_type.inserter_gui, position = defines.relative_gui_position.right, type = 'inserter', ghost_mode = 'both'}}) - frame.add({type = 'label', name = 'inserter_throughput', caption = 0, style = 'heading_2_label'}) - end + inserter.create(player) end local function gui_update(player, entity) - if not entity.valid or not entity.type then - return - end - - if entity.type ~= 'inserter' then - return - end - - if entity.type == 'entity-ghost' and entity.ghost_type ~= 'inserter' then - return - end - - player.gui.relative.phi_cl_inserter['inserter_throughput'].caption = string.format('%.2f', inserter.calc(entity)) + inserter.update(player, entity) end script.on_init(function() diff --git a/PHI-CL/control/inserter.lua b/PHI-CL/control/inserter.lua index b61958e..2c7d5c5 100644 --- a/PHI-CL/control/inserter.lua +++ b/PHI-CL/control/inserter.lua @@ -1,6 +1,27 @@ local main = {} +function main.create(player) + local frame = player.gui.relative.add({type = 'frame', name = 'phi_cl_inserter', anchor = {gui = defines.relative_gui_type.inserter_gui, position = defines.relative_gui_position.right, type = 'inserter', ghost_mode = 'both'}}) + frame.add({type = 'label', name = 'inserter_throughput', caption = 0, style = 'heading_2_label'}) +end + +function main.update(player, entity) + if not entity.valid or not entity.type then + return + end + + if entity.type ~= 'inserter' then + return + end + + if entity.type == 'entity-ghost' and entity.ghost_type ~= 'inserter' then + return + end + + player.gui.relative.phi_cl_inserter['inserter_throughput'].caption = string.format('%.2f', main.calc(entity)) +end + function main.calc(entity) local prototype = entity.type == 'entity-ghost' and entity.ghost_prototype or entity.prototype local pickup_target = entity.pickup_target and entity.pickup_target or entity.surface.find_entities_filtered{position = entity.pickup_position, limit = 1}[1]