Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipes with double of the same input cause a crash #161

Closed
Vizjereii opened this issue Jan 30, 2019 · 0 comments
Closed

Recipes with double of the same input cause a crash #161

Vizjereii opened this issue Jan 30, 2019 · 0 comments
Labels

Comments

@Vizjereii
Copy link

There is a crash happening if you select a recipe with same input doubled (in pyanodon's mods there is a building called Jig that requires two separate water inputs for example)

Error while running event helmod::on_gui_click (ID 1)
Gui element with name cell_water already present in the parent element.
stack traceback:
helmod/core/ElementGui.lua:842: in function 'addGuiTable'
helmod/core/ElementGui.lua:856: in function 'addCell'
helmod/core/ElementGui.lua:977: in function 'addCellElement'
helmod/tab/ProductionBlockTab.lua:396: in function 'addTableRow'
helmod/tab/ProductionBlockTab.lua:256: in function 'updateData'
helmod/tab/MainTab.lua:644: in function 'update'
helmod/tab/MainTab.lua:210: in function 'buildPanel'
helmod/core/MainPanel.lua:83: in function 'main'
helmod/controller/Controller.lua:182: in function 'onGuiClick'
helmod/core/Event.lua:195: in function <helmod/core/Event.lua:186

as a quick and dirty fix i hacked this together (this is my first time with lua so im sure this is incorrect, but at least it fixes the issue for me) in the addGuiTable function:

function ElementGui.addGuiTable(parent, key, column_count, style)
  local options = {}
  options.type = "table"
  options.column_count = column_count
  local isDuplicate = false
  for i, key_name in ipairs(parent.children_names) do
    if key_name == key then
    isDuplicate = true
    end
  end  
  if isDuplicate then
  options.name = "double_"..key
  else
  options.name = key
  end
  if style ~= nil then
    options.style = style
  end
  return parent.add(options)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants