Skip to content

API Queries

Marcel1853 edited this page Oct 9, 2026 · 1 revision

🇩🇪 Deutsche Version · ⬅ For mod authors

Queries

All queries return copies. The basics (stations, trains, goods keys) are on the page For mod authors.

Counters

Function Result
station_count() number of UTL stations
idle_train_count() number of free trains in depots
delivery_count() number of running deliveries
chained_count() how many deliveries were given out directly afterwards (without the depot)

Stations

Function Result
get_station(unit) copy of the station data: unit, kind, stop_name, config, provide, request, version; nil if unknown. config holds all settings, among them mode, roles, network, addon_role and ext (data of add-ons).
get_stations(filter?) list: unit, stop, stop_name, network, roles, addon_role, surface, force. filter = { surface = index, force = name, network = name, role = …, addon_role = "mod/name" }; role: "provider", "requester", "depot", "fuel", "cleanup", "storage".
get_trains_at_station(unit) { here = { ids of trains waiting there }, coming = { ids of trains whose delivery goes there next } }; nil if unknown
pending_trains(stop_unit) how many trains UTL sends by waypoint to this train stop (depot, refuelling, cleanup). Together with stop.trains_count this gives the occupancy against the train limit.

Deliveries

Function Result
get_deliveries() running deliveries: id, train_id, provider, requester, from, to, network, manifest, state, started, chained, extra_stops; with a second provider also second (station) and leg (1 or 2)
get_delivery(id) one running delivery (fields as above) or nil

state is to_provider, loading, to_requester or unloading. manifest = { [goods key] = amount }.

Trains

Function Result
get_train(train_id) what UTL knows about a train: id, idle (free in a depot), network, depot (name), depot_stop, delivery (id), service ("fuel", "cleanup", "both", "relocate" …), stuck_minutes, held_by (mod holding it); nil if UTL does not know it
get_idle_trains(filter?) free trains in depots: id, network, depot, length, surface, force. filter = { surface = index, force = name, network = name }. With { role = "mod/name" } instead the free trains in an add-on's depot (fields id, station, depot, length, surface, force, role).

Networks and teams

Function Result
get_networks(surface_index, force?) network names on a surface for a team, sorted
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): load_timeout, unload_timeout, timeout_mode
get_elevators() space elevators (Space Exploration only): per side unit, stop, opposite, surface, ok (finished and powered)

Network combinator, statistics, alerts

Function Result
get_readout(unit) network combinator: config (network, mode, star, transit) and values (last output signals per goods key); nil if unknown. mode: "stock", "storage", "demand", "shortage", "trains".
get_statistics() statistics as in the manager: since, deliveries, goods (per good ten, hour), trains (per train deliveries, utilization), stations (per station sent_ten, sent_hour, received_ten, received_hour) – over all surfaces and teams
get_alerts() latest alerts, newest first: key, group, icon, count, tick

Clone this wiki locally