Skip to content

Commit 2f96710

Browse files
committed
Determine factory name before barreling fluids
1 parent 622b072 commit 2f96710

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

mods/factoryplanner-is-exportable-to-fake-factorissimo/control.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ local function get_item_box_contents(root, item_box_index)
5959
return products
6060
end
6161

62+
local function get_factory_description(clipboard)
63+
local description = ""
64+
65+
for _, product in ipairs(clipboard.products) do
66+
description = description .. string.format('[%s=%s]', product.type, product.name)
67+
end
68+
description = description .. ' - '
69+
70+
if #clipboard.byproducts > 0 then
71+
for _, byproduct in ipairs(clipboard.byproducts) do
72+
description = description .. string.format('[%s=%s]', byproduct.type, byproduct.name)
73+
end
74+
description = description .. ' - '
75+
end
76+
77+
for _, ingredient in ipairs(clipboard.ingredients) do
78+
description = description .. string.format('[%s=%s]', ingredient.type, ingredient.name)
79+
end
80+
81+
return description
82+
end
83+
6284
script.on_event(defines.events.on_gui_opened, function(event)
6385
if event.gui_type ~= defines.gui_type.custom then return end
6486
if event.element.name ~= "fp_frame_main_dialog" then return end
@@ -203,6 +225,10 @@ script.on_event(defines.events.on_gui_click, function(event)
203225
end
204226
end
205227

228+
-- set the factory description before replacing fluids with barrels
229+
clipboard.factory_name = '' -- so the order gets preserved for the dump
230+
clipboard.factory_description = get_factory_description(clipboard)
231+
206232
do -- ensure all input/output fluids are barreled
207233
for i, product in ipairs(clipboard.products) do
208234
if product.type == "fluid" and global.can_be_barreled[product.name] then

mods/factoryplanner-is-exportable-to-fake-factorissimo/scripts/factory.lua

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,8 @@ function Factory.on_created_entity(event)
5151
use_rich_text = true,
5252
}
5353

54-
local io_string = ""
55-
56-
for _, product in ipairs(clipboard.products) do
57-
io_string = io_string .. string.format('[%s=%s]', product.type, product.name)
58-
end
59-
io_string = io_string .. ' - '
60-
61-
if #clipboard.byproducts > 0 then
62-
for _, byproduct in ipairs(clipboard.byproducts) do
63-
io_string = io_string .. string.format('[%s=%s]', byproduct.type, byproduct.name)
64-
end
65-
io_string = io_string .. ' - '
66-
end
67-
68-
for _, ingredient in ipairs(clipboard.ingredients) do
69-
io_string = io_string .. string.format('[%s=%s]', ingredient.type, ingredient.name)
70-
end
71-
7254
rendering.draw_text{
73-
text = io_string,
55+
text = clipboard.factory_description,
7456
color = {1, 1, 1},
7557
surface = entity.surface,
7658
target = entity,

0 commit comments

Comments
 (0)