"order" parameter for LuaGuiElement#add

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

"order" parameter for LuaGuiElement#add

Post by PFQNiet »

Having just implemented this myself in Lua, I figured I'd ask if this could be made part of the engine-side code:

Code: Select all

local function findIndexForNewElement(parent, order)
  local index = 1
  for i=1,#parent.children do
    if (parent.children[i].tags['order'] or "") < order then
      index = index + 1
    else
      break
    end
  end
  return index
end

local order = "a"
parent.add{
  -- ...
  tags = {order = order},
  index = findIndexForNewElement(parent, order)
}
It would be nice if instead I could just provide an "order" parameter to GUI elements I create, such that when a new GUI element is created with an order, it slots itself in the correct place, rather than me having to iterate through the elements on the Lua side.

Post Reply

Return to “Modding interface requests”