This commit is contained in:
2026-07-01 22:22:41 +09:00
parent 46fc20e7f9
commit 5f09d999b4
2 changed files with 23 additions and 17 deletions
+2 -17
View File
@@ -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()
+21
View File
@@ -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]