Skip to content

API Add on windows

Marcel1853 edited this page Oct 21, 2026 · 3 revisions

🇩🇪 Deutsche Version · ⬅ For mod authors

Add-ons: window and manager

Note

New in 0.0.20.

An add-on can have its own section in the station window and its own tab in the UTL Manager. UTL creates the space, the add-on builds the content.

Function Effect
register_gui_section{ mod, interface, build } section in the station window (right column or tab "Values", below the UTL sections)
register_manager_tab{ mod, interface, build, caption } tab in the UTL Manager, after the UTL tabs; caption = label (LocalisedString)

Register both in on_init and on_configuration_changed. If the function build does not exist in the interface, registering returns false and "unknown-function".

Calls

When Call
the station window is opened or rebuilt remote.call(interface, build, flow, station_unit, player_index) – flow is an empty vertical flow. If it stays empty, it disappears again (e.g. for stations without your role).
the manager tab is selected or ⟲ is pressed remote.call(interface, build, flow, player_index) – flow is the cleared content of the tab (880 × 560). It is not refreshed on a timer.
remote.add_interface("my-mod", {
  station_section = function(flow, unit, player_index)
    local data = remote.call("utl", "get_station_data", unit, "my-mod")
    if not data then return end            -- add nothing: the section disappears
    flow.add({ type = "label", caption = { "my-mod.tracks", data.tracks } })
  end,
  manager_tab = function(flow, player_index)
    flow.add({ type = "label", caption = "Sidings: …" })
  end,
})
remote.call("utl", "register_gui_section", { mod = "my-mod", interface = "my-mod", build = "station_section" })
remote.call("utl", "register_manager_tab", { mod = "my-mod", interface = "my-mod", build = "manager_tab",
  caption = { "my-mod.tab" } })

Input (clicks, checkboxes, text fields) in your own elements is handled by the add-on itself with its GUI events. The station window's flow carries the tag { utl_addon = mod }. If the content should change after input, the add-on rebuilds it in its flow itself.

Clone this wiki locally