Skip to content

For mod authors

Marcel1853 edited this page Sep 28, 2026 · 2 revisions

🇩🇪 Deutsche Version

For mod authors

UTL provides the remote interface utl for other mods, scenarios and the console.

/c game.print(serpent.line(remote.call("utl", "get_station", 123)))

Stations are addressed by their unit_number – for the UTL train stop the stop's, for the combinator the combinator's.

Queries

Function Result
station_count() number of UTL stations
idle_train_count() number of free trains in depots
delivery_count() number of running deliveries
get_station(unit) copy of the station data: unit, kind, stop_name, config, provide, request, version; nil if unknown
get_deliveries() list of running deliveries: id, train_id, provider, requester, from, to, network, manifest, state, started, chained
get_alerts() latest alerts, newest first: key, group, icon, count, tick
get_network_star(surface_index, name, force?) star of a network: role, center, partners
get_team_config(force_name, key) effective team value (own value or map value)

Good keys in provide, request and manifest have the form "type|name|quality", for example "item|iron-plate|normal" or "fluid|water|normal". A delivery's state is to_provider, loading, to_requester or unloading.

Changing things

Function Effect
configure_station(unit, changes) apply settings, e.g. { mode = "station", provide = true, request = false, request_priority = 5 }. Only known keys with a matching type. mode: "station", "depot", "fuel", "cleanup", "storage". Nested tables are merged one level deep, e.g. { cleanup = { offer = "first" } } keeps the goods list; storage: { mode = "storage", storage = { limits = { { signal = { type = "item", name = "iron-plate" }, min = 1000, max = 4000 } }, accept_leftover = true } }. Cleanup offer: false, "reserve", "normal", "first".
set_request(unit, slot, signal, count) set a request slot, e.g. set_request(unit, 1, { type = "item", name = "iron-plate" }, 400); signal = nil clears the slot.
copy_settings(from_unit, to_unit) copy all settings, like shift-click
tag_blueprint(blueprint, mapping, surface) write UTL settings into a blueprint created by script
link_networks(surface_index, center, partner, force?) link two networks into a star; limit from the force's research as in the game. Returns true or the reason as text.
unlink_networks(surface_index, a, b, force?) remove a link
set_team_config(force_name, key, value) set a team value: load_timeout, unload_timeout (seconds), timeout_mode ("and"/"or"); nil = map value. Team values only count when there are teams.
set_map_config(setting, value) set a map value like in the UTL Manager, e.g. set_map_config("utl-load-timeout", 10); nil = back to the mod settings value. Checks type and limits.

force is the force's name, default "player".

Example: blueprint with UTL settings

local mapping = stack.create_blueprint({ surface = surface, force = force, area = area })
remote.call("utl", "tag_blueprint", stack, mapping, surface)

Example: set up a station by script

local stop = surface.create_entity({ name = "utl-train-stop", position = pos, direction = defines.direction.east,
  force = "player", raise_built = true })
remote.call("utl", "configure_station", stop.unit_number, { mode = "station", provide = false, request = true })
remote.call("utl", "set_request", stop.unit_number, 1, { type = "item", name = "iron-plate" }, 4000)

Important

Build stations by script with raise_built = true, otherwise UTL does not learn about them. A station combinator is assigned to its stop through the wire on its output – so create it without raise_built, connect the wire, then call script.raise_script_built({ entity = combinator }).

Note

The interface grows with new versions. The source is on GitHub in scripts/api/remote.lua.

Clone this wiki locally