Flow style support of horizontal_spacing at runtime

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Kovus
Inserter
Inserter
Posts: 23
Joined: Sat Feb 27, 2016 5:25 pm
Contact:

Flow style support of horizontal_spacing at runtime

Post by Kovus »

I've noticed through some poking around that if I create a flow container, that I can pass it a predefined style which includes horizontal/vertical_spacing parameters. However, once that flow is instantiated, I cannot set the horizontal_spacing or vertical_spacing parameters on its style.

An example of it being used with a flow is noticeable in the mod-gui wrapper.

Code: Select all

  local button_flow = mod_flow.mod_gui_button_flow
  if not button_flow then
    button_flow = mod_flow.add{type = "flow", name = "mod_gui_button_flow", direction = "horizontal", style = "slot_table_spacing_flow_style"}
  end
For reference, these styles are defined in the base game:

Code: Select all

    table_spacing_flow_style =
    {
      type = "flow_style",
      horizontal_spacing = 5,
      vertical_spacing = 5
    },
    slot_table_spacing_flow_style =
    {
      type = "flow_style",
      horizontal_spacing = 2,
      vertical_spacing = 2
    },

In my own code, if I decide to change the style of the flow to increase the horizontal spacing, I can do that by using another defined style (see above).

Code: Select all

	local container = mod_gui.get_button_flow(player)
	container.style = 'table_spacing_flow_style'
	container.style.left_padding = 4
	container.style.top_padding = 4
Anything I put into that container would now have a horizontal spacing of 5 instead of 2.

However, I cannot modify the style.horizontal_spacing value directly for a flow:

Code: Select all

	local container = mod_gui.get_button_flow(player)
	container.style.horizontal_spacing = 5
Results in an error (filenames snipped for brevity):

Code: Select all

Error while running event
:127: Expected Table style type but was Flow.
:84: in function 'my_function'
...
Is this intentional behavior?

Post Reply

Return to “Modding interface requests”