Skip to content

Commit

Permalink
Fix Copy & paste functions reverting some production line settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Helfima committed Nov 17, 2024
1 parent b020580 commit 508d0e2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ Date: 2024-11-17
Features:
- Added quality selector for machine and module in recipe edition
Changes:
- Changed all button with sprite to implement quality
- Changed all tooltips to implement quality
- Changed default Amount affect one = 1, Beacon by factory = 1/8 and Constant beacon = 0 (new game)
- Model version modified at 2, migration to implement quality in the modules
Bugfixes:
- Fix error on accumulator recipe
- Fix Downloading a Production Line with spoiling recipe attempts to index a null factory
- Fix Copy & paste functions reverting some production line settings
---------------------------------------------------------------------------------------------------
Version: 2.0.6
Date: 2024-11-07
Expand Down
3 changes: 3 additions & 0 deletions data/Model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ end
---@param factory_fuel? string | FuelData
function Model.setFactory(recipe, factory_name, factory_quality, factory_fuel)
if recipe ~= nil then
if factory_quality == "" then
factory_quality = nil
end
local factory_prototype = EntityPrototype(factory_name)
if factory_prototype:native() ~= nil then
if recipe.factory == nil then
Expand Down
6 changes: 5 additions & 1 deletion data/ModelBuilder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,9 @@ function ModelBuilder.copyBlock(into_model, into_block, from_block)
local recipe_model = Model.newRecipe(into_model, recipe.name, recipe_prototype:getType())
recipe_model.index = child_index
recipe_model.production = recipe.production or 1
recipe_model.factory = ModelBuilder.copyFactory(recipe.factory)
if recipe.factory ~= nil then
recipe_model.factory = ModelBuilder.copyFactory(recipe.factory)
end
if recipe.beacons ~= nil then
recipe_model.beacons = {}
for _, beacon in pairs(recipe.beacons) do
Expand All @@ -705,6 +707,8 @@ function ModelBuilder.copyBlock(into_model, into_block, from_block)
into_block.by_factory = from_block.by_factory
into_block.by_product = from_block.by_product
into_block.by_limit = from_block.by_limit
into_block.solver = from_block.solver
into_block.consumer = from_block.consumer
if from_block.products ~= nil then
into_block.products = table.deepcopy(from_block.products)
end
Expand Down
2 changes: 1 addition & 1 deletion edition/RecipeEdition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function RecipeEdition:onEvent(event)
end

if event.action == "factory-select" then
Model.setFactory(recipe, event.item4)
Model.setFactory(recipe, event.item4, event.item5)
ModelBuilder.applyFactoryModulePriority(recipe)
ModelCompute.update(model)
self:update(event)
Expand Down
6 changes: 4 additions & 2 deletions gui/GuiButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ end
function GuiButton:choose_with_quality(element_type, element_name, element_quality)
self.options.type = "choose-elem-button"
self.options.elem_type = string.format("%s-with-quality", element_type)
self.options.elem_value = { name = element_name, quality = element_quality }
self.apply_elem_value = true
self.post_action["apply_elem_value"] = { name = element_name, quality = element_quality }
table.insert(self.name, element_name)
if element_quality ~= nil then
table.insert(self.name, element_quality)
end
return self
end

Expand Down
6 changes: 3 additions & 3 deletions gui/GuiElement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ function GuiElement.add(parent, gui_element)
if gui_element.classname ~= "HMGuiCell" then
local options = gui_element:getOptions()
element = parent.add(options)
if gui_element.apply_elem_value then
element.elem_value = options.elem_value
end
GuiElement.addPostAction(element, gui_element)
else
element = gui_element:create(parent)
Expand All @@ -219,6 +216,9 @@ function GuiElement.addPostAction(parent, gui_element)
if action_name == "mask_quality" then
GuiElement.maskQuality(parent, action.quality, action.size)
end
if action_name == "apply_elem_value" then
parent.elem_value = action
end
end
end

Expand Down
16 changes: 9 additions & 7 deletions migrations/helmod_2.0.7.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
function migration_priority(priority_module)
if priority_module == nil then return end
for _, module in pairs(priority_module) do
module.amount = module.value
module.value = nil
function migration_priority(module_priority)
if module_priority == nil then return end
for _, module in pairs(module_priority) do
if module.amount == nil then
module.amount = module.value
module.value = nil
end
end
end

Expand All @@ -29,8 +31,8 @@ function migration_factory(factory)
local new_modules = migration_modules(factory.modules)
factory.modules = new_modules
end
if factory.priority_module then
migration_priority(factory.priority_module)
if factory.module_priority then
migration_priority(factory.module_priority)
end
end

Expand Down

0 comments on commit 508d0e2

Please sign in to comment.