From 46735c7765ffe5d0fad2456306741bf29454e807 Mon Sep 17 00:00:00 2001 From: Helfima Date: Sun, 25 Aug 2019 16:40:29 +0200 Subject: [PATCH] Changed input text responsive Features: - Added fuel choose for burner factory Changes: - Changed input text responsive - Changed product edition (formula) Bugfixes: - Fixed tooltip in all locale --- changelog.txt | 10 + core/ElementGui.lua | 1 + core/Form.lua | 9 +- core/ModelCompute.lua | 461 ++++++++++++------------------------ core/global.lua | 18 ++ core/logging.lua | 6 +- edition/AbstractEdition.lua | 58 ++--- edition/ProductEdition.lua | 32 +-- edition/RecipeEdition.lua | 4 +- info.json | 2 +- locale/de/helmod.cfg | 2 +- locale/en/helmod.cfg | 1 + locale/fr/helmod.cfg | 2 +- locale/ru/helmod.cfg | 2 +- model/EntityPrototype.lua | 14 ++ model/Player.lua | 2 +- model/Product.lua | 4 +- model/RecipePrototype.lua | 19 +- tab/ProductionBlockTab.lua | 111 ++++----- 19 files changed, 316 insertions(+), 442 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4fff21fe..4e04b2b8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,14 @@ --------------------------------------------------------------------------------------------------- +Version: 0.9.1 +Date: 25. 08. 2019 + Features: + - Added fuel choose for burner factory + Changes: + - Changed input text responsive + - Changed product edition (formula) + Bugfixes: + - Fixed tooltip in all locale +--------------------------------------------------------------------------------------------------- Version: 0.9.0 Date: 23. 08. 2019 Changes: diff --git a/core/ElementGui.lua b/core/ElementGui.lua index 0e85f0a6..548217a5 100644 --- a/core/ElementGui.lua +++ b/core/ElementGui.lua @@ -484,6 +484,7 @@ function ElementGui.addGuiButtonSpriteStyled(parent, style, action, type, key, c end options.style = style if type ~= nil and key ~= nil then + if type == "resource" then type = "item" end options.sprite = type.."/"..key end diff --git a/core/Form.lua b/core/Form.lua index 8fe5a0a9..22816950 100644 --- a/core/Form.lua +++ b/core/Form.lua @@ -20,7 +20,7 @@ function Form.methods:init(parent) self.panelClose = true self.help_button = true self.auto_clear = true - + self.content_verticaly = true self:onInit(parent) end @@ -107,7 +107,12 @@ function Form.methods:getPanel() --menu_panel.style.horizontal_spacing = 10 menu_panel.style.horizontal_align = "right" - local content_panel = ElementGui.addGuiFlowV(flow_panel, "content_panel") + local content_panel + if self.content_verticaly then + content_panel = ElementGui.addGuiFlowV(flow_panel, "content_panel") + else + content_panel = ElementGui.addGuiFlowH(flow_panel, "content_panel") + end title_panel.drag_target = flow_panel --Logging:debug(self:classname(), "children",panel.children_names) return flow_panel, content_panel, menu_panel diff --git a/core/ModelCompute.lua b/core/ModelCompute.lua index 4d06511b..78adb139 100644 --- a/core/ModelCompute.lua +++ b/core/ModelCompute.lua @@ -136,18 +136,7 @@ function ModelCompute.update() ModelCompute.computeBlockByFactory(block) ModelCompute.computeBlockCleanInput(block) - - if block.solver == true then - local ok , err = pcall(function() - ModelCompute.computeSimplexBlock(block) - end) - if not(ok) then - Player.print("Matrix solver can not found solution!") - end - else - --ModelCompute.computeBlock(block) - ModelCompute.computeBlock2(block) - end + ModelCompute.computeBlock(block) -- compte les ingredients for _,ingredient in pairs(block.ingredients) do @@ -443,7 +432,7 @@ function ModelCompute.computeSimplexBlock(block) local recipes = block.recipes block.power = 0 block.count = 1 - + if recipes ~= nil then local mB,mC local mA, row_headers, col_headers = ModelCompute.getBlockMatrix(block) @@ -620,173 +609,183 @@ function ModelCompute.getBlockMatrix(block) local row_headers = {} local col_headers = {} local col_index = {} - local rows = {} - col_headers["R"] = {name="R", type="none"} -- Count recipe - col_headers["P"] = {name="P", type="none"} -- Production - col_headers["E"] = {name="E", type="none"} -- Energy - col_headers["C"] = {name="C", type="none"} -- Coefficient ou resultat - -- begin loop recipes - local irow = 1 - for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do - local row = {} + local rows = {} + col_headers["R"] = {name="R", type="none"} -- Count recipe + col_headers["P"] = {name="P", type="none"} -- Production + col_headers["E"] = {name="E", type="none"} -- Energy + col_headers["C"] = {name="C", type="none"} -- Coefficient ou resultat + -- begin loop recipes + local irow = 1 + for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do + local row = {} - local row_valid = false - local lua_recipe = RecipePrototype.load(recipe).native() + local row_valid = false + local lua_recipe = RecipePrototype.load(recipe).native() - -- prepare le taux de production - local production = 1 - if recipe.production ~= nil then production = recipe.production end - table.insert(row_headers,{name=recipe.name, type=recipe.type, tooltip=recipe.name.."\nRecette"}) - row["R"] = 0 - row["P"] = production - row["E"] = RecipePrototype.getEnergy() - row["C"] = 0 + -- prepare le taux de production + local production = 1 + if recipe.production ~= nil then production = recipe.production end + table.insert(row_headers,{name=recipe.name, type=recipe.type, tooltip=recipe.name.."\nRecette"}) + row["R"] = 0 + row["P"] = production + row["E"] = RecipePrototype.getEnergy() + row["C"] = 0 - ModelCompute.computeModuleEffects(recipe) - --ModelCompute.computeFactory(recipe) + ModelCompute.computeModuleEffects(recipe) + --ModelCompute.computeFactory(recipe) - -- preparation - local lua_products = {} - local lua_ingredients = {} - for i, lua_product in pairs(RecipePrototype.getProducts()) do - lua_products[lua_product.name] = {name=lua_product.name, type=lua_product.type, count = Product.load(lua_product).getAmount(recipe)} + -- preparation + local lua_products = {} + local lua_ingredients = {} + for i, lua_product in pairs(RecipePrototype.getProducts()) do + lua_products[lua_product.name] = {name=lua_product.name, type=lua_product.type, count = Product.load(lua_product).getAmount(recipe)} + end + for i, lua_ingredient in pairs(RecipePrototype.getIngredients(recipe.factory)) do + if lua_ingredients[lua_ingredient.name] == nil then + lua_ingredients[lua_ingredient.name] = {name=lua_ingredient.name, type=lua_ingredient.type, count = Product.load(lua_ingredient).getAmount()} + else + lua_ingredients[lua_ingredient.name].count = lua_ingredients[lua_ingredient.name].count + Product.load(lua_ingredient).getAmount() end - for i, lua_ingredient in pairs(RecipePrototype.getIngredients(recipe.factory)) do - if lua_ingredients[lua_ingredient.name] == nil then - lua_ingredients[lua_ingredient.name] = {name=lua_ingredient.name, type=lua_ingredient.type, count = Product.load(lua_ingredient).getAmount()} - else - lua_ingredients[lua_ingredient.name].count = lua_ingredients[lua_ingredient.name].count + Product.load(lua_ingredient).getAmount() - end + end + + + for name, lua_product in pairs(lua_products) do + local index = 1 + if col_index[name] ~= nil then + index = col_index[name] end - - - for name, lua_product in pairs(lua_products) do - local index = 1 - if col_index[name] ~= nil then - index = col_index[name] - end - col_index[name] = index + col_index[name] = index - local col_name = name..index - col_headers[col_name] = {name=lua_product.name, type=lua_product.type, is_ingredient = false, tooltip=col_name.."\nProduit"} - row[col_name] = lua_product.count - row_valid = true + local col_name = name..index + col_headers[col_name] = {name=lua_product.name, type=lua_product.type, is_ingredient = false, tooltip=col_name.."\nProduit"} + row[col_name] = lua_product.count + row_valid = true + end + Logging:debug(ModelCompute.classname, "----> ingredient", recipe.name, lua_ingredients) + for name, lua_ingredient in pairs(lua_ingredients) do + local index = 1 + -- cas normal de l'ingredient n'existant pas du cote produit + if col_index[name] ~= nil and lua_products[name] == nil then + index = col_index[name] end - Logging:debug(ModelCompute.classname, "----> ingredient", recipe.name, lua_ingredients) - for name, lua_ingredient in pairs(lua_ingredients) do - local index = 1 - -- cas normal de l'ingredient n'existant pas du cote produit - if col_index[name] ~= nil and lua_products[name] == nil then + -- cas de l'ingredient existant du cote produit + if col_index[name] ~= nil and lua_products[name] ~= nil then + -- cas de la valeur equivalente, on creer un nouveau element + if lua_products[name].count == lua_ingredients[name].count or recipe.type == "resource" then + index = col_index[name]+1 + else index = col_index[name] end - -- cas de l'ingredient existant du cote produit - if col_index[name] ~= nil and lua_products[name] ~= nil then - -- cas de la valeur equivalente, on creer un nouveau element - if lua_products[name].count == lua_ingredients[name].count or recipe.type == "resource" then - index = col_index[name]+1 - else - index = col_index[name] - end - end - col_index[name] = index - - local col_name = name..index - col_headers[col_name] = {name=lua_ingredient.name, type=lua_ingredient.type, is_ingredient = true, tooltip=col_name.."\nIngredient"} - row[col_name] = ( row[col_name] or 0 ) - lua_ingredients[name].count - row_valid = true end + col_index[name] = index - if row_valid then - table.insert(rows,row) - end + local col_name = name..index + col_headers[col_name] = {name=lua_ingredient.name, type=lua_ingredient.type, is_ingredient = true, tooltip=col_name.."\nIngredient"} + row[col_name] = ( row[col_name] or 0 ) - lua_ingredients[name].count + row_valid = true end - -- end loop recipes - Logging:debug(ModelCompute.classname, "----> matrix col headers", col_headers) - Logging:debug(ModelCompute.classname, "----> matrix row headers", row_headers) - Logging:debug(ModelCompute.classname, "----> matrix rows", rows) - - -- on bluid A correctement - local mA = {} - for _,row in pairs(rows) do - local rowA = {} - for column,_ in pairs(col_headers) do - if row[column] ~= nil then - table.insert(rowA, row[column]) - else - table.insert(rowA, 0) - end - end - table.insert(mA, rowA) + if row_valid then + table.insert(rows,row) end + end - local row_input = {} - local input_ready = {} - for column,col_header in pairs(col_headers) do - if block.input ~= nil and block.input[col_header.name] and not(input_ready[col_header.name]) then - table.insert(row_input, block.input[col_header.name]) - input_ready[col_header.name] = true + -- end loop recipes + Logging:debug(ModelCompute.classname, "----> matrix col headers", col_headers) + Logging:debug(ModelCompute.classname, "----> matrix row headers", row_headers) + Logging:debug(ModelCompute.classname, "----> matrix rows", rows) + + -- on bluid A correctement + local mA = {} + for _,row in pairs(rows) do + local rowA = {} + for column,_ in pairs(col_headers) do + if row[column] ~= nil then + table.insert(rowA, row[column]) else - table.insert(row_input, 0) + table.insert(rowA, 0) end end - table.insert(mA, 1, row_input) - table.insert(row_headers,1, {name="Input", type="none"}) - table.insert(row_headers, {name="Z", type="none"}) + table.insert(mA, rowA) + end - Logging:debug(ModelCompute.classname, "----> matrix A", mA) - if User.getModGlobalSetting("debug") ~= "none" then - local row_headers2 = {} - for _,row in pairs(row_headers) do - table.insert(row_headers2, row.name) - end - local col_headers2 = {} - for _,col in pairs(col_headers) do - table.insert(col_headers2, col.name) - end - Logging:debug(ModelCompute.classname, "----> export matrix A", game.table_to_json({col_headers=col_headers2 ,row_headers=row_headers2 ,matrix=mA})) + local row_input = {} + local input_ready = {} + for column,col_header in pairs(col_headers) do + if block.input ~= nil and block.input[col_header.name] and not(input_ready[col_header.name]) then + table.insert(row_input, block.input[col_header.name]) + input_ready[col_header.name] = true + else + table.insert(row_input, 0) + end + end + table.insert(mA, 1, row_input) + table.insert(row_headers,1, {name="Input", type="none"}) + table.insert(row_headers, {name="Z", type="none"}) + + Logging:debug(ModelCompute.classname, "----> matrix A", mA) + if User.getModGlobalSetting("debug") ~= "none" then + local row_headers2 = {} + for _,row in pairs(row_headers) do + table.insert(row_headers2, row.name) + end + local col_headers2 = {} + for _,col in pairs(col_headers) do + table.insert(col_headers2, col.name) end - return mA, row_headers, col_headers + Logging:debug(ModelCompute.classname, "----> export matrix A", game.table_to_json({col_headers=col_headers2 ,row_headers=row_headers2 ,matrix=mA})) + end + return mA, row_headers, col_headers end end ------------------------------------------------------------------------------- -- Compute production block -- --- @function [parent=#ModelCompute] computeBlock2 +-- @function [parent=#ModelCompute] computeBlock -- -- @param #table block block of model -- -function ModelCompute.computeBlock2(block) +function ModelCompute.computeBlock(block) Logging:debug(ModelCompute.classname, "computeBlock()", block.name) local recipes = block.recipes block.power = 0 block.count = 1 - + if recipes ~= nil then - local mB,mC + local mB,mC,my_solver local mA, row_headers, col_headers = ModelCompute.getBlockMatrix(block) if mA ~= nil then if User.getModGlobalSetting("debug") ~= "none" then - block.matrix1 = {} - block.matrix1.col_headers = col_headers - block.matrix1.row_headers = row_headers - block.matrix1.mA = mA + block.matrix = {} + block.matrix.col_headers = col_headers + block.matrix.row_headers = row_headers + block.matrix.mA = mA + end + + if block.solver == true then + my_solver = Simplex.new(mA) + else + my_solver = Solver.new(mA) end - Solver.new(mA) + local ok , err = pcall(function() + mC = my_solver.solve() + mB = my_solver.getMx() + end) + if not(ok) then + Player.print("Matrix solver can not found solution!") + end - mC = Solver.solve() - mB = Solver.getMx() Logging:debug(ModelCompute.classname, "----> matrix B", mB) Logging:debug(ModelCompute.classname, "----> matrix C", mC) if User.getModGlobalSetting("debug") ~= "none" then - block.matrix1.mB = mB - block.matrix1.mC = mC + block.matrix.mB = mB + block.matrix.mC = mC end end if mC ~= nil then @@ -794,12 +793,12 @@ function ModelCompute.computeBlock2(block) local ratio = 1 local ratioRecipe = nil -- calcul ordonnee sur les recipes du block - local row_index = Solver.row_input + 1 + local row_index = my_solver.row_input + 1 for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do Logging:debug(ModelCompute.classname , "solver index", recipe.name, row_index) ModelCompute.computeModuleEffects(recipe) - local icol = 1 - recipe.count = mC[row_index][icol] + recipe.count = mC[row_index][1] + recipe.production = mC[row_index][2] row_index = row_index + 1 Logging:debug(ModelCompute.classname , "----> solver solution", recipe.name, icol, recipe.count) @@ -844,7 +843,7 @@ function ModelCompute.computeBlock2(block) end -- finalisation du bloc for icol,state in pairs(mC[1]) do - if icol > Solver.col_start then + if icol > my_solver.col_start then local Z = math.abs(mC[#mC][icol]) local product_header = product_headers[icol] local product = Product.load(product_header).new() @@ -892,179 +891,7 @@ function ModelCompute.computeBlock2(block) end end -------------------------------------------------------------------------------- --- Compute production block --- --- @function [parent=#ModelCompute] computeBlock --- --- @param #table block block of model --- -function ModelCompute.computeBlock(block) - Logging:debug(ModelCompute.classname, "********** computeBlock **********") - local model = Model.getModel() - - local recipes = block.recipes - if recipes ~= nil then - - if block.input ~= nil then - local input_computed = {} - for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do - local lua_recipe = RecipePrototype.load(recipe).native() - -- prepare le taux de production - local production = 1 - if recipe.production ~= nil then production = recipe.production end - -- initialise la premiere recette avec le input - for _, lua_product in pairs(RecipePrototype.getProducts()) do - local product = Product.load(lua_product).new() - if input_computed[product.name] == nil and block.input[product.name] ~= nil then - local p_amount = product.amount - local i_amount = 0 - - -- consolide product.count - -- exclus le type ressource ou fluid - if recipe.type ~= "resource" and recipe.type ~= "fluid" then - for k, lua_ingredient in pairs(RecipePrototype.getIngredients(recipe.factory)) do - if lua_ingredient.name == product.name then - local ingredient = Product.load(lua_ingredient).new() - i_amount = ingredient.amount - end - end - end - - if block.ingredients[product.name] == nil then - block.ingredients[product.name] = { - name = product.name, - type = "fake", - amount = 0, - count = 0 - } - end - block.ingredients[product.name].count = block.input[product.name] * (p_amount/(p_amount-i_amount)) - input_computed[product.name] = true - end - end - end - end - - Logging:debug(ModelCompute.classname , "********** initialized:", block) - - -- ratio pour le calcul du nombre de block - local ratio = 1 - local ratioRecipe = nil - -- calcul ordonnee sur les recipes du block - for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do - ModelCompute.computeModuleEffects(recipe) - - if recipe.type == "technology" then - ModelCompute.computeBlockTechnology(block, recipe) - else - ModelCompute.computeBlockRecipe(block, recipe) - end - - ModelCompute.computeFactory(recipe) - - block.power = block.power + recipe.energy_total - - if type(recipe.factory.limit) == "number" and recipe.factory.limit > 0 then - local currentRatio = recipe.factory.limit/recipe.factory.count - if currentRatio < ratio then - ratio = currentRatio - ratioRecipe = recipe.index - -- block number - block.count = recipe.factory.count/recipe.factory.limit - -- subblock energy - block.sub_power = 0 - if block.count ~= nil and block.count > 0 then - block.sub_power = math.ceil(block.power/block.count) - end - end - end - - Logging:debug(ModelCompute.classname , "********** Compute before clean:", block) - - local lua_recipe = RecipePrototype.load(recipe).native() - -- reduit les produits du block - -- state = 0 => produit - -- state = 1 => produit pilotant - -- state = 2 => produit restant - for _, lua_product in pairs(RecipePrototype.getProducts()) do - local count = Product.load(lua_product).countProduct(recipe) - if count > 0 then - -- compte les produits - if block.products[lua_product.name] ~= nil then - block.products[lua_product.name].count = block.products[lua_product.name].count + count - end - -- consomme les produits - if block.ingredients[lua_product.name] ~= nil then - block.ingredients[lua_product.name].count = block.ingredients[lua_product.name].count - count - end - end - end - Logging:debug(ModelCompute.classname , "********** Compute after clean product:", block) - for _, lua_ingredient in pairs(RecipePrototype.getIngredients(recipe.factory)) do - local count = Product.load(lua_ingredient).countIngredient(recipe) - if count > 0 then - -- consomme les ingredients - -- exclus le type ressource ou fluid - if recipe.type ~= "resource" and recipe.type ~= "fluid" and block.products[lua_ingredient.name] ~= nil and block.mining_ingredient ~= lua_ingredient.name then - block.products[lua_ingredient.name].count = block.products[lua_ingredient.name].count - count - if RecipePrototype.isVoid() then - block.ingredients[lua_ingredient.name].count = block.ingredients[lua_ingredient.name].count - count - end - end - end - end - Logging:debug(ModelCompute.classname , "********** Compute after clean ingredient:", block) - end - - -- control zero state 1 - local count_state_1 = 0 - for _, product in pairs(block.products) do - if bit32.band(product.state, 1) > 0 then count_state_1 = count_state_1 + 1 end - end - Logging:debug(ModelCompute.classname , "product.state = 1", count_state_1) - if count_state_1 == 0 then - for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do - for _, product in pairs(RecipePrototype.load(recipe).getProducts()) do - if block.products[product.name] ~= nil then - block.products[product.name].state = 1 - end - end - break - end - end - Logging:debug(ModelCompute.classname , "block.products", block.products) - if block.count < 1 then - block.count = 1 - end - - -- reduit les engredients fake du block - for _, ingredient in pairs(block.ingredients) do - if ingredient.type == "fake" then block.ingredients[ingredient.name] = nil end - end - - -- reduit les produits du block - for _, product in pairs(block.products) do - -- change le satuts si exedant - if block.ingredients[product.name] ~= nil and count_state_1 ~= 0 and block.mining_ingredient ~= product.name and not(RecipePrototype.isVoid()) then - product.state = 2 - end - if block.products[product.name].count < ModelCompute.waste_value and not(bit32.band(product.state, 1) > 0) then - block.products[product.name] = nil - end - end - - -- reduit les ingredients du block - for _, ingredient in pairs(block.ingredients) do - if block.ingredients[ingredient.name].count < ModelCompute.waste_value then - block.ingredients[ingredient.name] = nil - end - end - Logging:debug(ModelCompute.classname , "computeBlock end", block) - end -end - -------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- -- Compute module effects of factory -- -- @function [parent=#ModelCompute] computeModuleEffects @@ -1100,7 +927,9 @@ function ModelCompute.computeModuleEffects(recipe) factory.effects.consumption = factory.effects.consumption + value * consumption_bonus * distribution_effectivity * beacon.combo end end - + if recipe.type == "resource" then + factory.effects.productivity = factory.effects.productivity + Player.getForce().mining_drill_productivity_bonus + end -- cap la vitesse a self.capSpeed if factory.effects.speed < Model.capSpeed then factory.effects.speed = Model.capSpeed end @@ -1126,11 +955,7 @@ function ModelCompute.computeFactory(recipe) -- effet consumption local energy_type = EntityPrototype.load(recipe.factory).getEnergyType() - if energy_type ~= "burner" then - recipe.factory.energy = EntityPrototype.load(recipe.factory).getEnergyUsage() * (1 + recipe.factory.effects.consumption) - else - recipe.factory.energy = 0 - end + recipe.factory.energy = EntityPrototype.load(recipe.factory).getEnergyUsage() * (1 + recipe.factory.effects.consumption) -- compte le nombre de machines necessaires local model = Model.getModel() @@ -1147,7 +972,11 @@ function ModelCompute.computeFactory(recipe) recipe.beacon.energy = EntityPrototype.load(recipe.beacon).getEnergyUsage() -- calcul des totaux - recipe.factory.energy_total = math.ceil(recipe.factory.count*recipe.factory.energy) + if energy_type == "electrical" then + recipe.factory.energy_total = math.ceil(recipe.factory.count*recipe.factory.energy) + else + recipe.factory.energy_total = 0 + end recipe.beacon.energy_total = math.ceil(recipe.beacon.count*recipe.beacon.energy) recipe.energy_total = recipe.factory.energy_total + recipe.beacon.energy_total -- arrondi des valeurs diff --git a/core/global.lua b/core/global.lua index 47cd35c6..f634d343 100644 --- a/core/global.lua +++ b/core/global.lua @@ -38,4 +38,22 @@ function spairs(t, order) return keys[i], t[keys[i]] end end +end + +------------------------------------------------------------------------------- +-- formula +-- +-- @function formula +-- +-- @param operation +-- +function formula(operation) + if operation == nil or operation == "" then return 0 end + local allowed = false + for i=1, string.len(operation) do + if not(string.find(operation,"[0-9.()/*-+]+",i)) then + error({code=1}) + end + end + return load("return " .. operation)() end \ No newline at end of file diff --git a/core/logging.lua b/core/logging.lua index fff54390..eae424ab 100644 --- a/core/logging.lua +++ b/core/logging.lua @@ -56,7 +56,11 @@ function Logging:objectToString(object, level) elseif type(object) == "function" then message = message.."\"__function\"" elseif object.isluaobject then - message = message..string.format("{\"type\":%q,\"name\":%q}", object.type, object.name) + if object.valid then + message = message..string.format("{\"type\":%q,\"name\":%q}", object.type, object.name) + else + message = message.."invalid object" + end elseif type(object) == "table" then if level <= self.limit then local first = true diff --git a/edition/AbstractEdition.lua b/edition/AbstractEdition.lua index 88817b6d..09a9ad84 100644 --- a/edition/AbstractEdition.lua +++ b/edition/AbstractEdition.lua @@ -517,12 +517,12 @@ function AbstractEdition.methods:updateFactoryInfo(item, item2, item3) ElementGui.addGuiLabel(inputPanel, "label-energy", ({"helmod_label.energy"})) - if EntityPrototype.getEnergyType() == "electrical" then - local sign = "" - if factory.effects.consumption > 0 then sign = "+" end - ElementGui.addGuiLabel(inputPanel, "energy", Format.formatNumberKilo(factory.energy, "W").." ("..sign..Format.formatPercent(factory.effects.consumption).."%)") - else + local sign = "" + if factory.effects.consumption > 0 then sign = "+" end + ElementGui.addGuiLabel(inputPanel, "energy", Format.formatNumberKilo(factory.energy, "W").." ("..sign..Format.formatPercent(factory.effects.consumption).."%)") + if EntityPrototype.getEnergyType() == "burner" then + ElementGui.addGuiLabel(inputPanel, "label-burner", ({"helmod_common.resource"})) local fuel_list = Player.getChemicalFuelItemPrototypes() local items = {} for _,item in pairs(fuel_list) do @@ -540,12 +540,15 @@ function AbstractEdition.methods:updateFactoryInfo(item, item2, item3) local sign = "" if factory.effects.productivity > 0 then sign = "+" end ElementGui.addGuiLabel(inputPanel, "label-productivity", ({"helmod_label.productivity"})) - ElementGui.addGuiLabel(inputPanel, "productivity", sign..Format.formatPercent(factory.effects.productivity).."%") + local productivity_tooltip = nil + if object.type == "resource" then + --productivity_tooltip = ({"gui-bonus.mining-drill-productivity-bonus"}) + end + ElementGui.addGuiLabel(inputPanel, "productivity", sign..Format.formatPercent(factory.effects.productivity).."%",nil,productivity_tooltip) ElementGui.addGuiLabel(inputPanel, "label-limit", ({"helmod_label.limit"}), nil, {"tooltip.factory-limit"}) - ElementGui.addGuiText(inputPanel, "limit", factory.limit, "helmod_textfield", {"tooltip.factory-limit"}) + ElementGui.addGuiText(inputPanel, string.format("%s=factory-update=ID=%s=%s", self:classname(), item, object.id), factory.limit, "helmod_textfield", {"tooltip.factory-limit"}) - ElementGui.addGuiButton(infoPanel, self:classname().."=factory-update=ID="..item.."=", object.id, "helmod_button_default", ({"helmod_button.update"})) end end @@ -627,7 +630,7 @@ function AbstractEdition.methods:updateFactorySelector(item, item2, item3) local selectorPanel = self:getFactorySelectorPanel() selectorPanel.clear() - + local scrollPanel = ElementGui.addGuiScrollPane(selectorPanel, "scroll-factory", helmod_scroll_style.recipe_list, true) local object = self:getObject(item, item2, item3) @@ -718,12 +721,10 @@ function AbstractEdition.methods:updateBeaconInfo(item, item2, item3) ElementGui.addGuiLabel(inputPanel, "efficiency", EntityPrototype.getDistributionEffectivity()) ElementGui.addGuiLabel(inputPanel, "label-combo", ({"helmod_label.beacon-on-factory"}), nil, {"tooltip.beacon-on-factory"}) - ElementGui.addGuiText(inputPanel, "combo", beacon.combo, "helmod_textfield", {"tooltip.beacon-on-factory"}) + ElementGui.addGuiText(inputPanel, string.format("%s=beacon-update=ID=%s=%s=%s", self:classname(), item, object.id, "combo"), beacon.combo, "helmod_textfield", {"tooltip.beacon-on-factory"}) ElementGui.addGuiLabel(inputPanel, "label-factory", ({"helmod_label.factory-per-beacon"}), nil, {"tooltip.factory-per-beacon"}) - ElementGui.addGuiText(inputPanel, "factory", beacon.factory, "helmod_textfield", {"tooltip.factory-per-beacon"}) - - ElementGui.addGuiButton(infoPanel, self:classname().."=beacon-update=ID="..item.."=", object.id, "helmod_button_default", ({"helmod_button.update"})) + ElementGui.addGuiText(inputPanel, string.format("%s=beacon-update=ID=%s=%s=%s", self:classname(), item, object.id, "factory"), beacon.factory, "helmod_textfield", {"tooltip.factory-per-beacon"}) end end @@ -809,7 +810,7 @@ function AbstractEdition.methods:updateBeaconSelector(item, item2, item3) local selectorPanel = self:getBeaconSelectorPanel() selectorPanel.clear() - + local scrollPanel = ElementGui.addGuiScrollPane(selectorPanel, "scroll-beacon", helmod_scroll_style.recipe_list, true) local object = self:getObject(item, item2, item3) @@ -892,13 +893,9 @@ function AbstractEdition.methods:onEvent(event, action, item, item2, item3) if Player.isAdmin() or model.owner == Player.native().name or (model.share ~= nil and bit32.band(model.share, 2) > 0) then if action == "object-update" then - local inputPanel = self:getObjectInfoPanel(player)["table-input"] local options = {} - - if inputPanel["production"] ~= nil then - options["production"] = (ElementGui.getInputNumber(inputPanel["production"]) or 100)/100 - end - + local text = event.element.text + options["production"] = (tonumber(text) or 100)/100 ModelBuilder.updateObject(item, item2, options) ModelCompute.update() self:updateObjectInfo(item, item2, item3) @@ -917,9 +914,8 @@ function AbstractEdition.methods:onEvent(event, action, item, item2, item3) local inputPanel = self:getFactoryInfoPanel()["table-input"] local options = {} - if inputPanel["limit"] ~= nil then - options["limit"] = ElementGui.getInputNumber(inputPanel["limit"]) - end + local text = event.element.text + options["limit"] = tonumber(text) or 0 ModelBuilder.updateFactory(item, item2, options) ModelCompute.update() @@ -927,7 +923,7 @@ function AbstractEdition.methods:onEvent(event, action, item, item2, item3) end if action == "factory-fuel-update" then - + local index = event.element.selected_index local fuel_list = Player.getChemicalFuelItemPrototypes() local items = {} @@ -935,7 +931,7 @@ function AbstractEdition.methods:onEvent(event, action, item, item2, item3) for _,item in pairs(fuel_list) do if index == 1 then options.fuel = item.name - break end + break end index = index - 1 end ModelBuilder.updateFuelFactory(item, item2, options) @@ -964,16 +960,10 @@ function AbstractEdition.methods:onEvent(event, action, item, item2, item3) end if action == "beacon-update" then - local inputPanel = self:getBeaconInfoPanel()["table-input"] local options = {} - - if inputPanel["combo"] ~= nil then - options["combo"] = ElementGui.getInputNumber(inputPanel["combo"]) - end - - if inputPanel["factory"] ~= nil then - options["factory"] = ElementGui.getInputNumber(inputPanel["factory"]) - end + local text = event.element.text + -- item3 = "combo" or "factory" + options[item3] = tonumber(text) or 0 ModelBuilder.updateBeacon(item, item2, options) ModelCompute.update() diff --git a/edition/ProductEdition.lua b/edition/ProductEdition.lua index f2f959f6..805125a5 100644 --- a/edition/ProductEdition.lua +++ b/edition/ProductEdition.lua @@ -5,7 +5,7 @@ -- @extends #AbstractEdition -- -ProductEdition = setclass("HMProductEdition", AbstractEdition) +ProductEdition = setclass("HMProductEdition", Form) ------------------------------------------------------------------------------- -- On initialization @@ -143,7 +143,7 @@ function ProductEdition.methods:onUpdate(event, action, item, item2, item3) end self:updateInfo(item, item2, item3) - self:updateTool(item, item2, item3) + --self:updateTool(item, item2, item3) self:updateAction(item, item2, item3) end @@ -168,7 +168,7 @@ function ProductEdition.methods:updateInfo(item, item2, item3) ElementGui.addGuiLabel(tablePanel, "product-label", Player.getLocalisedName(product)) ElementGui.addGuiLabel(tablePanel, "quantity-label", ({"helmod_common.quantity"})) - ElementGui.addGuiText(tablePanel, "quantity", product_count or 0) + ElementGui.addGuiText(tablePanel, string.format("%s=product-update=ID=%s=%s",self:classname(),item,product.name), product_count or 0, nil, ({"tooltip.formula-allowed"})) end end @@ -187,9 +187,7 @@ function ProductEdition.methods:updateAction(item, item2, item3) if product ~= nil then action_panel.clear() local action_panel = ElementGui.addGuiTable(action_panel,"table_action",3) - ElementGui.addGuiButton(action_panel, self:classname().."=product-update=ID="..item.."=", product.name, "helmod_button_default", ({"helmod_button.save"})) ElementGui.addGuiButton(action_panel, self:classname().."=product-reset=ID="..item.."=", product.name, "helmod_button_default", ({"helmod_button.reset"})) - ElementGui.addGuiButton(action_panel, self:classname().."=CLOSE=ID="..item.."=", product.name, "helmod_button_default", ({"helmod_button.close"})) end end @@ -211,7 +209,7 @@ function ProductEdition.methods:updateTool(item, item2, item3) ItemPrototype.load("transport-belt").getLocalisedName() ElementGui.addGuiLabel(table_panel, "quantity-label", {"helmod_product-edition-panel.transport-belt"}) ElementGui.addGuiText(table_panel, "quantity", belt_count) - + local table_panel = ElementGui.addGuiTable(tool_panel,"table-belt",5) for key, prototype in pairs(Player.getEntityPrototypes({"transport-belt"})) do ElementGui.addGuiButtonSelectSprite(table_panel, self:classname().."=element-select=ID=", Player.getEntityIconType(prototype), prototype.name, prototype.name, EntityPrototype.load(prototype).getLocalisedName()) @@ -234,14 +232,20 @@ function ProductEdition.methods:onEvent(event, action, item, item2, item3) if Player.isAdmin() or model.owner == Player.native().name or (model.share ~= nil and bit32.band(model.share, 2) > 0) then if action == "product-update" then local products = {} - local input_panel = self:getInfoPanel()["table-header"] - local quantity = ElementGui.getInputNumber(input_panel["quantity"]) - ModelBuilder.updateProduct(item, item2, quantity) - ModelCompute.update() - self:close() - Event.force_open = true - Event.force_refresh = true + local operation = event.element.text + local ok , err = pcall(function() + local quantity = formula(operation) + + ModelBuilder.updateProduct(item, item2, quantity) + ModelCompute.update() + self:close() + Event.force_open = true + Event.force_refresh = true + end) + if not(ok) then + Player.print("Formula is not valid!") + end end if action == "product-reset" then local products = {} @@ -257,7 +261,7 @@ function ProductEdition.methods:onEvent(event, action, item, item2, item3) local input_panel = self:getToolPanel()["table-header"] local belt_count = ElementGui.getInputNumber(input_panel["quantity"]) local belt_speed = EntityPrototype.load(item).getBeltSpeed() - + local output_panel = self:getInfoPanel()["table-header"] ElementGui.setInputNumber(output_panel["quantity"], belt_count * belt_speed * Product.belt_ratio) end diff --git a/edition/RecipeEdition.lua b/edition/RecipeEdition.lua index e6285796..26a1917a 100644 --- a/edition/RecipeEdition.lua +++ b/edition/RecipeEdition.lua @@ -19,6 +19,7 @@ RecipeEdition = setclass("HMRecipeEdition", AbstractEdition) function RecipeEdition.methods:onInit(parent) self.panelCaption = ({"helmod_recipe-edition-panel.title"}) self.parameterLast = string.format("%s_%s",self:classname(),"last") + self.content_verticaly = true end ------------------------------------------------------------------------------- @@ -155,9 +156,8 @@ function RecipeEdition.methods:updateObjectInfo(item, item2, item3) local tablePanel = ElementGui.addGuiTable(info_panel,"table-input",3) ElementGui.addGuiLabel(tablePanel, "label-production", ({"helmod_recipe-edition-panel.production"})) - ElementGui.addGuiText(tablePanel, "production", (recipe.production or 1)*100, "helmod_textfield") + ElementGui.addGuiText(tablePanel, string.format("%s=object-update=ID=%s=%s", self:classname(), item, recipe.id), (recipe.production or 1)*100, "helmod_textfield") - ElementGui.addGuiButton(tablePanel, self:classname().."=object-update=ID="..item.."=", recipe.id, "helmod_button_default", ({"helmod_button.update"})) end end end \ No newline at end of file diff --git a/info.json b/info.json index 7c98645c..239c81e4 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "helmod", - "version": "0.9.0", + "version": "0.9.1", "title": "Helmod: assistant for planning your base.", "author": "Helfima", "contact": "Helfima", diff --git a/locale/de/helmod.cfg b/locale/de/helmod.cfg index f73f8057..1c614209 100644 --- a/locale/de/helmod.cfg +++ b/locale/de/helmod.cfg @@ -229,7 +229,7 @@ module-description=__1__\nVerbrauch: __2__%\nGeschwindigkeit: __3__%\nProduktivi element-amount=__1__\nAnzahl: __2__ element-amount-probability=__1__\nMindestanzahl: __2__\nMaximalanzahl: __3__\nWahrscheinlichkeit: __4__ recipe-info=__1__ __2__\nProdukte: __3__ \nZutaten: __4__ -recipe-info-element=\n __1__ x __2__ __3__ +recipe-info-element=\n __1____2__ x __3__ __4__ cargo-info=__1__ \n__2__\n__3__ cargo-info-element=__1__: __2__ technology-info=__1__\nStufe: __2__ \nSchema: __3__ \nZutaten: __4__ diff --git a/locale/en/helmod.cfg b/locale/en/helmod.cfg index 0d2b7a61..9eda92f1 100644 --- a/locale/en/helmod.cfg +++ b/locale/en/helmod.cfg @@ -276,6 +276,7 @@ unlink-element=Link/Unlink this recipe factory-limit=Limit of this factory for the block beacon-on-factory=Number of beacon affecting one factory factory-per-beacon=Number of factory per beacon +formula-allowed=Formula is allowed. ex: (10*5-3)/2 [controls] helmod-input-valid=Input valid diff --git a/locale/fr/helmod.cfg b/locale/fr/helmod.cfg index 9db6e07d..4e71a2a3 100644 --- a/locale/fr/helmod.cfg +++ b/locale/fr/helmod.cfg @@ -241,7 +241,7 @@ module-description=__1__\nConsommation: __2__%\nVitesse: __3__%\nProductivité: element-amount=__1__\nQuantité: __2__ element-amount-probability=__1__\nQuantité min: __2__\nQuantité max: __3__\nProbabilité: __4__ recipe-info=__1__ __2__\nProduits: __3__ \nIngredients: __4__ -recipe-info-element=\n __1__ x __2__ __3__ +recipe-info-element=\n __1____2__ x __3__ __4__ recipe-by-hand=(Manuel) recipe-unsearched=(Non recherché) cargo-info=__1__ \n__2__\n__3__ diff --git a/locale/ru/helmod.cfg b/locale/ru/helmod.cfg index 44492134..e256775c 100644 --- a/locale/ru/helmod.cfg +++ b/locale/ru/helmod.cfg @@ -198,7 +198,7 @@ module-description=__1__\nПотребление: __2__%\nСкорость: __3_ element-amount=__1__\nКоличество: __2__ element-amount-probability=__1__\nКоличество мин: __2__\nКоличество макс: __3__\nВероятность: __4__ recipe-info=__1__ __2__\nProduits: __3__ \nIngredients: __4__ -recipe-info-element=\n __1__ x __2__ __3__ +recipe-info-element=\n __1____2__ x __3__ __4__ technology-info=__1__\nLevel: __2__ \nFormula: __3__ \nIngredients: __4__ share-mod=Allow __1__ in multiplayers unlink-element=Link/Unlink this recipe diff --git a/model/EntityPrototype.lua b/model/EntityPrototype.lua index 6f84965b..04bb8b7a 100644 --- a/model/EntityPrototype.lua +++ b/model/EntityPrototype.lua @@ -452,6 +452,20 @@ function EntityPrototype.getBurnerEffectivity() return 0 end +------------------------------------------------------------------------------- +-- Return burner energy source prototype emissions +-- +-- @function [parent=#EntityPrototype] getBurnerEmissions +-- +-- @return #number default 0 +-- +function EntityPrototype.getBurnerEmissions() + if lua_entity_prototype ~= nil and lua_entity_prototype.burner_prototype ~= nil then + return lua_entity_prototype.burner_prototype.emissions or 1 + end + return 0 +end + ------------------------------------------------------------------------------- -- Return inventory size -- diff --git a/model/Player.lua b/model/Player.lua index 09e9f390..d62ab663 100644 --- a/model/Player.lua +++ b/model/Player.lua @@ -426,7 +426,7 @@ function Player.getProductionsCrafting(category, lua_recipe) if not(rules_included[category]) and not(rules_included[category]) then -- standard recipe if lua_entity.crafting_categories ~= nil and lua_entity.crafting_categories[category] then - local recipe_ingredient_count = RecipePrototype.load(lua_recipe, "recipe").getIngredientCount(lua_entity) + local recipe_ingredient_count = RecipePrototype.load(lua_recipe, "recipe").getIngredientCount() local factory_ingredient_count = EntityPrototype.load(lua_entity).getIngredientCount() Logging:debug(Player.classname, "crafting", recipe_ingredient_count, factory_ingredient_count) if factory_ingredient_count >= recipe_ingredient_count then diff --git a/model/Product.lua b/model/Product.lua index 3da755e1..dcd3dc3a 100644 --- a/model/Product.lua +++ b/model/Product.lua @@ -229,9 +229,7 @@ function Product.getProductivityBonus(recipe) Logging:trace(Product.classname, "getProductivityBonus(recipe)", lua_product) if recipe.isluaobject or recipe.factory == nil or recipe.factory.effects == nil then return 1 end local productivity = recipe.factory.effects.productivity - if recipe.type == "resource" then - productivity = productivity + Player.getForce().mining_drill_productivity_bonus - end + return productivity end diff --git a/model/RecipePrototype.lua b/model/RecipePrototype.lua index a875558d..dbdfb57e 100644 --- a/model/RecipePrototype.lua +++ b/model/RecipePrototype.lua @@ -283,7 +283,22 @@ function RecipePrototype.getIngredients(factory) if lua_prototype ~= nil then local factory_fuel = "coal" if lua_type == "recipe" then - return lua_prototype.ingredients + local ingredients = lua_prototype.ingredients + EntityPrototype.load(factory) + if factory ~= nil and EntityPrototype.getEnergyType() == "burner" then + local energy_usage = EntityPrototype.getEnergyUsage() + local burner_effectivity = EntityPrototype.getBurnerEffectivity() + --local burner_emission = EntityPrototype.getBurnerEmissions() + local speed_factory = EntityPrototype.getCraftingSpeed() + factory_fuel = factory.fuel or factory_fuel + + --Logging:debug(RecipePrototype.classname, "burner", energy_usage,speed_factory,burner_effectivity,burner_emission) + local fuel_value = energy_usage*speed_factory*(1/1.26) + local burner_count = fuel_value/ItemPrototype.load(factory_fuel).getFuelValue() + local burner_ingredient = {name=factory_fuel, type="item", amount=burner_count} + table.insert(ingredients, burner_ingredient) + end + return ingredients elseif lua_type == "resource" then local ingredients = {{name=lua_prototype.name, type="item", amount=1}} -- ajouter le liquide obligatoire, s'il y en a @@ -301,9 +316,11 @@ function RecipePrototype.getIngredients(factory) if factory ~= nil and EntityPrototype.getEnergyType() == "burner" then local energy_usage = EntityPrototype.getEnergyUsage() local burner_effectivity = EntityPrototype.getBurnerEffectivity() + --local burner_emission = EntityPrototype.getBurnerEmissions() local mining_speed = EntityPrototype.getMiningSpeed() factory_fuel = factory.fuel or factory_fuel local speed_factory = hardness * mining_speed / mining_time + --Logging:debug(RecipePrototype.classname, "resource burner", energy_usage,speed_factory,burner_effectivity,burner_emission) local fuel_value = energy_usage*speed_factory*12.5 local burner_count = fuel_value/ItemPrototype.load(factory_fuel).getFuelValue() local burner_ingredient = {name=factory_fuel, type="item", amount=burner_count} diff --git a/tab/ProductionBlockTab.lua b/tab/ProductionBlockTab.lua index 13a388c5..012ac616 100644 --- a/tab/ProductionBlockTab.lua +++ b/tab/ProductionBlockTab.lua @@ -67,9 +67,9 @@ function ProductionBlockTab.methods:updateDebugPanel(item, item2, item3) Logging:debug("ProductionBlockTab", "updateDebugPanel():", item, item2, item3) local header_panel1, header_panel2,scroll_panel1, scroll_panel2 = self:getResultScrollPanel2({"helmod_result-panel.tab-button-production-block"}) local model = Model.getModel() - + local current_block = User.getParameter("current_block") or "new" - + local countRecipes = Model.countBlockRecipes(current_block) if countRecipes > 0 then @@ -106,74 +106,57 @@ function ProductionBlockTab.methods:updateDebugPanel(item, item2, item3) end - if block.solver == true then - -- *** Simplex Method *** - if block.matrix2 ~= nil then - -- matrix A - local ma_panel = ElementGui.addGuiFrameV(scroll_panel2, "ma_panel", helmod_frame_style.hidden, "Matrix A") - self:buildMatrix(ma_panel, block.matrix2.mA, block.matrix2.row_headers, block.matrix2.col_headers) + if block.matrix ~= nil then + -- matrix A + local ma_panel = ElementGui.addGuiFrameV(scroll_panel2, "ma_panel", helmod_frame_style.hidden, "Matrix A") + self:buildMatrix(ma_panel, block.matrix.mA, block.matrix.row_headers, block.matrix.col_headers) - if block.matrix2.mB then - local col_headers2 = {} - for _,col_header in pairs(block.matrix2.col_headers) do - table.insert(col_headers2,col_header) - end + if block.matrix.mB then + local col_headers2 = {} + for _,col_header in pairs(block.matrix.col_headers) do + table.insert(col_headers2,col_header) + end + if block.solver == true then table.insert(col_headers2,{name="T", type="none"}) - for i,row_header in pairs(block.matrix2.row_headers) do - if i > 1 and i < #block.matrix2.row_headers then + for i,row_header in pairs(block.matrix.row_headers) do + if i > 1 and i < #block.matrix.row_headers then table.insert(col_headers2,row_header) end end - local row_headers2 = {} - for i,row_header in pairs(block.matrix2.row_headers) do - if i < #block.matrix2.row_headers then - table.insert(row_headers2,row_header) - end + end + + local row_headers2 = {} + if block.solver == true then + table.insert(row_headers2,{name="input", type="none"}) + for i=1, (#block.matrix.mB - 3) do + table.insert(row_headers2,{name="", type="none"}) end - for i,row_header in pairs(block.matrix2.mB) do - if i > #block.matrix2.row_headers then - table.insert(row_headers2,{name="", type="none"}) + table.insert(row_headers2,{name="T", type="none"}) + else + for i,row_header in pairs(block.matrix.row_headers) do + if i < #block.matrix.row_headers then + table.insert(row_headers2,row_header) end end - table.insert(row_headers2,{name="Z", type="none"}) + end + table.insert(row_headers2,{name="Z", type="none"}) - -- matrix B - local mb_panel = ElementGui.addGuiFrameV(scroll_panel2, "mb_panel", helmod_frame_style.hidden, "Matrix B") - self:buildMatrix(mb_panel, block.matrix2.mB, row_headers2, col_headers2) + -- matrix B + local mb_panel = ElementGui.addGuiFrameV(scroll_panel2, "mb_panel", helmod_frame_style.hidden, "Matrix B") + self:buildMatrix(mb_panel, block.matrix.mB, row_headers2, col_headers2) - -- matrix C - row_headers2 = {} - table.insert(row_headers2,{name="State", type="none"}) - for _,col_header in pairs(block.matrix2.row_headers) do - table.insert(row_headers2,col_header) + local row_headers2 = {} + table.insert(row_headers2,{name="State", type="none"}) + for i,row_header in pairs(block.matrix.row_headers) do + if i < #block.matrix.row_headers then + table.insert(row_headers2,row_header) end - - local mc_panel = ElementGui.addGuiFrameV(scroll_panel2, "mc_panel", helmod_frame_style.hidden, "Matrix C") - self:buildMatrix(mc_panel, block.matrix2.mC, row_headers2, block.matrix2.col_headers) end - end - else - -- *** Normal Method *** - if block.matrix1 ~= nil then - -- matrix A - local ma_panel = ElementGui.addGuiFrameV(scroll_panel2, "ma_panel", helmod_frame_style.hidden, "Matrix A") - self:buildMatrix(ma_panel, block.matrix1.mA, block.matrix1.row_headers, block.matrix1.col_headers) - - if block.matrix1.mB then - -- matrix B - local mb_panel = ElementGui.addGuiFrameV(scroll_panel2, "mb_panel", helmod_frame_style.hidden, "Matrix B") - self:buildMatrix(mb_panel, block.matrix1.mB, block.matrix1.row_headers, block.matrix1.col_headers) - - local row_headers2 = {} - table.insert(row_headers2,{name="State", type="none"}) - for _,col_header in pairs(block.matrix1.row_headers) do - table.insert(row_headers2,col_header) - end + table.insert(row_headers2,{name="Z", type="none"}) - -- matrix C - local mc_panel = ElementGui.addGuiFrameV(scroll_panel2, "mc_panel", helmod_frame_style.hidden, "Matrix C") - self:buildMatrix(mc_panel, block.matrix1.mC, row_headers2, block.matrix1.col_headers) - end + -- matrix C + local mc_panel = ElementGui.addGuiFrameV(scroll_panel2, "mc_panel", helmod_frame_style.hidden, "Matrix C") + self:buildMatrix(mc_panel, block.matrix.mC, row_headers2, block.matrix.col_headers) end end @@ -309,8 +292,8 @@ function ProductionBlockTab.methods:updateInput(item, item2, item3) local element = model.blocks[current_block] -- input panel - local input_table = ElementGui.addGuiTable(input_scroll,"input-table", ElementGui.getElementColumnNumber(50), "helmod_table_element") - if element.ingredients ~= nil then + local input_table = ElementGui.addGuiTable(input_scroll,"input-table", ElementGui.getElementColumnNumber(50)-2, "helmod_table_element") + if element.ingredients ~= nil then for index, lua_product in pairs(element.ingredients) do local ingredient = Product.load(lua_product).new() ingredient.count = lua_product.count @@ -352,7 +335,7 @@ function ProductionBlockTab.methods:updateOutput(item, item2, item3) local element = model.blocks[current_block] -- ouput panel - local output_table = ElementGui.addGuiTable(output_scroll,"output-table", ElementGui.getElementColumnNumber(50), "helmod_table_element") + local output_table = ElementGui.addGuiTable(output_scroll,"output-table", ElementGui.getElementColumnNumber(50)-2, "helmod_table_element") if element.products ~= nil then for index, lua_product in pairs(element.products) do local product = Product.load(lua_product).new() @@ -397,10 +380,10 @@ function ProductionBlockTab.methods:updateData(item, item2, item3) -- data panel local header_panel1, header_panel2,scroll_panel1, scroll_panel2 = self:getResultScrollPanel2({"helmod_result-panel.tab-button-production-block"}) - + local back_button = ElementGui.addGuiButton(header_panel1,self:classname().."=change-tab=ID=","HMProductionLineTab","back_button","Back") back_button.style.width = 70 - + local recipe_table = ElementGui.addGuiTable(scroll_panel1,"recipe-data",1) recipe_table.vertical_centering = false @@ -414,7 +397,7 @@ function ProductionBlockTab.methods:updateData(item, item2, item3) end local block_new = {name = "helmod_button_icon_robot_flat2" ,count = 0,localised_name = "helmod_result-panel.add-button-production-block"} ElementGui.addCellProduct(cell_recipe, block_new, self:classname().."=change-tab=ID=HMProductionBlockTab=new=", true, "tooltip.edit-block", color) - + for _, block in spairs(model.blocks, function(t,a,b) return t[b]["index"] > t[a]["index"] end) do -- col recipe local color = "gray" @@ -428,7 +411,7 @@ function ProductionBlockTab.methods:updateData(item, item2, item3) if last_element ~= nil then scroll_panel1.scroll_to_element(last_element) end - + local countRecipes = Model.countBlockRecipes(current_block) -- production block result if countRecipes > 0 then