Skip to content

Commit

Permalink
Reworked custom fluid recipe created by offshore-pump
Browse files Browse the repository at this point in the history
  Changes:
    - Reworked custom fluid recipe created by offshore-pump
    - Implemented productivity bonus on recipe when technoly researched (need refresh sheet)
  Bugfixes:
    - Fix error on accumulator recipe
    - Fix search recipe in boiler recipes when click a ingredient or a product
    - Fix limitation message when module is not usable (module priority)
    - Fix copy block parameters (copy or download)
  • Loading branch information
Helfima committed Nov 6, 2024
1 parent 1daefb0 commit 665b45b
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 77 deletions.
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---------------------------------------------------------------------------------------------------
Version: 2.0.5
Date: 2024-11-06
Changes:
- Reworked custom fluid recipe created by offshore-pump
- Implemented productivity bonus on recipe when technoly researched (need refresh sheet)
Bugfixes:
- Fix error on accumulator recipe
- Fix search recipe in boiler recipes when click a ingredient or a product
- Fix limitation message when module is not usable (module priority)
- Fix copy block parameters (copy or download)
---------------------------------------------------------------------------------------------------
Version: 2.0.4
Date: 2024-10-29
Changes:
Expand Down
4 changes: 4 additions & 0 deletions controller/Controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ require "selector.RecipeSelector"
require "selector.TechnologySelector"
require "selector.ItemSelector"
require "selector.FluidSelector"
require "selector.TileSelector"

require "model.Prototype"
require "model.ElectricPrototype"
Expand All @@ -45,6 +46,7 @@ require "model.ItemPrototype"
require "model.Product"
require "model.RecipePrototype"
require "model.Technology"
require "model.TilePrototype"

ModGui = require "mod-gui"
Cache = require "data.Cache"
Expand Down Expand Up @@ -96,6 +98,7 @@ function Controller:prepare()
table.insert(forms, TechnologySelector("HMTechnologySelector"))
table.insert(forms, ItemSelector("HMItemSelector"))
table.insert(forms, FluidSelector("HMFluidSelector"))
table.insert(forms, TileSelector("HMTileSelector"))

table.insert(forms, LogisticEdition("HMLogisticEdition"))
table.insert(forms, ModelEdition("HMModelEdition"))
Expand Down Expand Up @@ -131,6 +134,7 @@ function Controller:on_init()
table.insert(forms, TechnologySelector("HMTechnologySelector"))
table.insert(forms, ItemSelector("HMItemSelector"))
table.insert(forms, FluidSelector("HMFluidSelector"))
table.insert(forms, TileSelector("HMTileSelector"))
for _,form in pairs(forms) do
form:prepare()
end
Expand Down
22 changes: 16 additions & 6 deletions data/ModelBuilder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,6 @@ function ModelBuilder.copyBlock(into_model, into_block, from_block)
if is_block then
local new_block = Model.newBlock(into_model, child)
new_block.index = child_index
new_block.unlinked = child.by_factory and true or false
new_block.by_factory = child.by_factory
new_block.by_product = child.by_product
new_block.by_limit = child.by_limit
into_model.blocks[new_block.id] = new_block
ModelBuilder.copyBlock(into_model, new_block, child)
into_block.children[new_block.id] = new_block
Expand All @@ -680,8 +676,8 @@ function ModelBuilder.copyBlock(into_model, into_block, from_block)
end
end

if recipe.contraint ~= nil then
recipe_model.contraint = table.deepcopy(recipe.contraint)
if recipe.contraints ~= nil then
recipe_model.contraints = table.deepcopy(recipe.contraints)
end
into_block.children[recipe_model.id] = recipe_model
child_index = child_index + 1
Expand All @@ -691,9 +687,23 @@ function ModelBuilder.copyBlock(into_model, into_block, from_block)
end
if into_block ~= nil then
table.reindex_list(into_block.children)
into_block.unlinked = from_block.unlinked
into_block.by_factory = from_block.by_factory
into_block.by_product = from_block.by_product
into_block.by_limit = from_block.by_limit
if from_block.products ~= nil then
into_block.products = table.deepcopy(from_block.products)
end
if from_block.ingredients ~= nil then
into_block.ingredients = table.deepcopy(from_block.ingredients)
end
if from_block.products_linked ~= nil then
into_block.products_linked = table.deepcopy(from_block.products_linked)
end
if from_block.contraints ~= nil then
into_block.contraints = table.deepcopy(from_block.contraints)
end

end
end
end
Expand Down
14 changes: 7 additions & 7 deletions data/ModelCompute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function ModelCompute.update(model)
if model ~= nil and model.blocks ~= nil then
-- Add parameters
Model.appendParameters(model)
model.input = {}
ModelCompute.updateBlock(model, model.block_root)
ModelCompute.finalizeBlock(model.block_root, 1)
model.version = Model.version
Expand Down Expand Up @@ -597,13 +596,14 @@ end
---@return RecipeData
function ModelCompute.computeModuleEffects(recipe, parameters)
local factory = recipe.factory
factory.effects = { speed = 0, productivity = 0, consumption = 0, pollution = 0, quality = 0 }
local recipe_productivity = Player.getRecipeProductivityBonus(recipe.name)
factory.effects = { speed = 0, productivity = recipe_productivity, consumption = 0, pollution = 0, quality = 0 }
if parameters ~= nil then
factory.effects.speed = parameters.effects.speed
factory.effects.productivity = parameters.effects.productivity
factory.effects.consumption = parameters.effects.consumption
factory.effects.pollution = parameters.effects.pollution
factory.effects.quality = parameters.effects.quality or 0
factory.effects.speed = factory.effects.speed + (parameters.effects.speed or 0)
factory.effects.productivity = factory.effects.productivity + (parameters.effects.productivity or 0)
factory.effects.consumption = factory.effects.consumption + (parameters.effects.consumption or 0)
factory.effects.pollution = factory.effects.pollution + (parameters.effects.pollution or 0)
factory.effects.quality = factory.effects.quality + (parameters.effects.quality or 0)
end
factory.cap = { speed = 0, productivity = 0, consumption = 0, pollution = 0 }
local factory_prototype = EntityPrototype(factory)
Expand Down
1 change: 1 addition & 0 deletions dialog/AdminPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ function AdminPanel:onEvent(event)
table.insert(forms, TechnologySelector("HMTechnologySelector"))
table.insert(forms, ItemSelector("HMItemSelector"))
table.insert(forms, FluidSelector("HMFluidSelector"))
table.insert(forms, TileSelector("HMTileSelector"))
for _,form in pairs(forms) do
if event.item2 == form.classname then
form:prepare()
Expand Down
42 changes: 26 additions & 16 deletions dialog/PropertiesPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function PropertiesPanel:onEvent(event)
if api ~= nil then
Cache.setData(self.classname, "runtime_api", api)
end
self:updateData(event)
end
end

Expand All @@ -209,18 +210,21 @@ end
function PropertiesPanel:updateRuntimeApi(event)
local scroll_panel = self:getRuntimeApiTab()
scroll_panel.clear()
local url_frame = GuiElement.add(scroll_panel, GuiFlowH())
url_frame.style.horizontal_spacing = 5
GuiElement.add(url_frame, GuiLabel("json_label"):caption("URL to find Runtime API"))
local json_url = GuiElement.add(url_frame,
GuiTextField("json_url"):text("https://lua-api.factorio.com/latest/runtime-api.json"))


local json_table = GuiElement.add(scroll_panel, GuiTable("table-resources"):column(3))
json_table.style.cell_padding = 5

GuiElement.add(json_table, GuiLabel("json_label"):caption("URL to find Runtime API"))
local json_url = GuiElement.add(json_table, GuiTextField("json_url"):text("https://lua-api.factorio.com/latest/runtime-api.json"))
json_url.style.width = 600
GuiElement.add(json_table, GuiFlow())

local json_frame = GuiElement.add(scroll_panel, GuiFlowV())
json_frame.style.vertical_spacing = 5
local json_string = GuiElement.add(json_frame, GuiTextBox("json_string"))
GuiElement.add(json_table, GuiLabel("json_string_label"):caption("Json String"))
local json_string = GuiElement.add(json_table, GuiTextField("json_string"))
json_string.style.width = 600
GuiElement.add(json_frame, GuiButton(self.classname, "import-runtime-api"):caption("Import Runtime API"))

GuiElement.add(json_table, GuiButton(self.classname, "import-runtime-api"):caption("Import Runtime API"))
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -249,6 +253,7 @@ function PropertiesPanel:updateMenu(event)
GuiElement.add(action_panel, GuiButton("HMFluidSelector", "OPEN", "HMPropertiesPanel"):caption({ "helmod_result-panel.select-button-fluid" }))
GuiElement.add(action_panel, GuiButton("HMRecipeSelector", "OPEN", "HMPropertiesPanel"):caption({ "helmod_result-panel.select-button-recipe" }))
GuiElement.add(action_panel, GuiButton("HMTechnologySelector", "OPEN", "HMPropertiesPanel"):caption({"helmod_result-panel.select-button-technology" }))
GuiElement.add(action_panel, GuiButton("HMTileSelector", "OPEN", "HMPropertiesPanel"):caption({ "helmod_result-panel.select-button-tile" }))
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -282,8 +287,7 @@ function PropertiesPanel:updateData(event)
data[properties.name][key] = properties
end
end
local result_table = GuiElement.add(content_panel,
GuiTable("table-resources"):column(#prototype_compare + 1):style("helmod_table-rule-odd"))
local result_table = GuiElement.add(content_panel, GuiTable("table-resources"):column(#prototype_compare + 1):style("helmod_table-rule-odd"))

self:addTableHeader(result_table, prototype_compare)

Expand Down Expand Up @@ -348,13 +352,17 @@ function PropertiesPanel:addTableHeader(itable, prototype_compare)
icon_type = "fluid"
localised_name = fluid_prototype:getLocalisedName()
elseif string.find(prototype.type, "recipe") then
local recipe_protoype = RecipePrototype(prototype)
icon_type = recipe_protoype:getType()
localised_name = recipe_protoype:getLocalisedName()
local recipe_prototype = RecipePrototype(prototype)
icon_type = recipe_prototype:getType()
localised_name = recipe_prototype:getLocalisedName()
elseif prototype.type == "technology" then
local technology_protoype = Technology(prototype)
local technology_prototype = Technology(prototype)
icon_type = "technology"
localised_name = technology_protoype:getLocalisedName()
localised_name = technology_prototype:getLocalisedName()
elseif prototype.type == "tile" then
local tile_prototype = TilePrototype(prototype)
icon_type = "tile"
localised_name = tile_prototype:getLocalisedName()
end
local cell_header = GuiElement.add(itable, GuiFlowH("header", prototype.name, index))
GuiElement.add(cell_header,
Expand Down Expand Up @@ -525,6 +533,8 @@ function PropertiesPanel:getPrototypeData(prototype)
lua_prototype = RecipePrototype(prototype):native()
elseif prototype.type == "technology" then
lua_prototype = Technology(prototype):native()
elseif prototype.type == "tile" then
lua_prototype = TilePrototype(prototype):native()
end
if lua_prototype ~= nil then
local properties = self:parseProperties(lua_prototype, 0)
Expand Down
1 change: 1 addition & 0 deletions edition/ParametersEdition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function ParametersEdition:updateEffects(event)

GuiElement.add(block_table, GuiLabel("label-pollution"):caption({ "description.pollution-bonus" }))
GuiElement.add(block_table, GuiTextField(self.classname, "change-effect", "pollution"):text(Format.formatNumberElement((effects.pollution or 1)*100)):style("helmod_textfield"))

end

-------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions edition/RecipeEdition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,10 @@ function RecipeEdition:updateFactoryModulesPriority(factory_module_panel)
local module = ItemPrototype(element.name)
local tooltip = GuiTooltipModule("tooltip.add-module"):element({type="item", name=element.name}):withControlInfo(control_info)
if Player.checkFactoryLimitationModule(module:native(), recipe) == false then
if (module:native().limitation_message_key ~= nil) and (module:native().limitation_message_key ~= "") then
tooltip = {"item-limitation."..module:native().limitation_message_key}
local limitation_message = Player.getFactoryLimitationModuleMessage(module:native(), recipe);

if limitation_message ~= nil then
tooltip = limitation_message
else
tooltip = ""
end
Expand Down
2 changes: 1 addition & 1 deletion gui/GuiCell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function GuiCell:add_icon_info(button, info_icon)
end
if type == "fluid" then
tooltip = "tooltip.resource-recipe"
sprite_name = GuiElement.getSprite(defines.sprite_info.developer)
sprite_name = GuiElement.getSprite(defines.sprite_info.mining)
end
if type == "resource" then
tooltip = "tooltip.resource-recipe"
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helmod",
"version": "2.0.4",
"version": "2.0.5",
"title": "Helmod: Assistant for planning your factory",
"author": "Helfima",
"contact": "Helfima",
Expand Down
6 changes: 6 additions & 0 deletions locale/en/helmod.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ fluid-title=Fluid selector
recipe-title=Recipe selector
technology-title=Technology selector
container-title=Container selector
tile-title=Tile selector

[helmod_product-edition-panel]
title=Edit Product
Expand Down Expand Up @@ -319,6 +320,7 @@ select-button-fluid=Select fluid
select-button-recipe=Select recipe
select-button-technology=Select technology
select-button-container=Select container
select-button-tile=Select tile
row-button-delete=X
row-button-up=U
row-button-down=D
Expand Down Expand Up @@ -518,3 +520,7 @@ helmod=Helmod
[helmod_bug-repport-panel]
title=Bug Repport
no_error=No errors to report

[helmod_limitation]
no-module-slot=No module slot
not-allowed-category-module=Not allowed '__1__' category module
10 changes: 9 additions & 1 deletion locale/fr/helmod.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ fluid-title=Fluid selector
recipe-title=Sélecteur de recette
technology-title=Sélecteur de technologie
container-title=Sélecteur de conteneur
tile-title=Sélecteur de tuile

[helmod_product-edition-panel]
title=Edition de produit
Expand Down Expand Up @@ -290,6 +291,7 @@ select-button-fluid=Sélectionner un fluide
select-button-recipe=Sélectionner une recette
select-button-technology=Sélectionner une technologie
select-button-container=Sélectionner un container
select-button-tile=Sélectionner une tuile
row-button-delete=X
row-button-up=U
row-button-down=D
Expand Down Expand Up @@ -402,6 +404,8 @@ info-module=Information module
add-module=Ajouter ce module
remove-module=Supprimer ce module
remove-element=Supprimer cette ligne
remove-block-confirm=Êtes-vous sûr de vouloir ce bloc ?
remove-block-cancel=Annuler la suppression de bloc
remove-element_confirm=Êtes-vous sûr de vouloir cette ligne ?
remove-element_cancel=Annuler la suppression de cette ligne
up-element=Monter cette ligne\n__CONTROL_STYLE_BEGIN__Maj + Clic__CONTROL_STYLE_END__: Monter de __1__ lignes\n__CONTROL_STYLE_BEGIN__Ctrl + Click__CONTROL_STYLE_END__: Monter à la première ligne
Expand Down Expand Up @@ -459,4 +463,8 @@ excessive-event-iteration=Le nombre d'itération sur les événements a été d
[helmod_bug-repport-panel]
title=Rapport de Bug
no_error=Aucune erreur à rapporter
no_error=Aucune erreur à rapporter
[helmod_limitation]
no-module-slot=Aucun emplacement pour module
not-allowed-category-module=Catégorie de module '__1__' non autorisée
4 changes: 2 additions & 2 deletions model/EnergySourcePrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ end
---@return number --default 0
function ElectricSourcePrototype:getInputFlowLimit()
if self.lua_prototype ~= nil then
return (self.lua_prototype.input_flow_limit or 0) * 60
return (self.lua_prototype.get_input_flow_limit() or 0) * 60
end
return 0
end
Expand All @@ -141,7 +141,7 @@ end
---@return number --default 0
function ElectricSourcePrototype:getOutputFlowLimit()
if self.lua_prototype ~= nil then
return (self.lua_prototype.output_flow_limit or 0) * 60
return (self.lua_prototype.get_output_flow_limit() or 0) * 60
end
return 0
end
Expand Down
Loading

0 comments on commit 665b45b

Please sign in to comment.