Repository navigation
API Performance
Marcel1853 edited this page Oct 10, 2026
·
3 revisions
🇩🇪 Deutsche Version · ⬅ For mod authors
UTL is built for many trains and high UPS and keeps the interface cheap. Each mod is responsible for its own performance – here is when UTL calls something and what gets expensive.
| What | When | How often |
|---|---|---|
| delivery events | on creation, on every state change, at the end | a few times per delivery |
on_train_arrived / on_train_departed
|
when a train stops at / leaves a UTL station | once per stop |
on_train_idle |
when a train stands free in a depot | once per depot visit |
on_train_rebuilt |
when a train UTL knows is rebuilt | rarely |
on_job_finished |
at the end of a job | once per job |
| station events | when a station is built, removed or changed | rarely |
on_alert |
on every UTL alert (with its repeat lock) | rarely |
on_request_unserved |
when a requester waits too long without a train | at most once per minute per request |
| train filter | only for trips from/to an add-on role, once per dispatch attempt | if no train is found, again every few seconds |
| section in the station window | when the window is opened or rebuilt | rarely |
| manager tab | when the tab is selected or ⟲ | rarely |
Without an add-on none of this costs anything: callbacks only happen when something is registered. Events without a listener are almost free. Nothing is called every tick.
-
On events only remember, calculate later. Doing a lot of work on every arrival slows the game
down. Better remember the data and work through it in small portions in your own
on_nth_tick(fixed budget per run). - Keep train filters fast: only go through the list and look up your own stored data – no path finding, no searching for entities inside the filter.
-
Path finding for jobs and inserted stops:
send_jobandadd_delivery_stopcheck by path finding that the target is reachable; for a waypoint by position (withoutrail_direction) the same search also finds the direction. On big maps a search can take a few milliseconds (measured: up to about 10 ms with 384 trains and 880 stations). To save it, give rail and direction directly and setskip_path_check = truewhen the target is surely reachable. -
get_stationfor many stations copies all settings every time – in a loop over hundreds of stations rather getget_stationsonce and remember the values you need. -
Do not query lists on a timer:
get_stations,get_idle_trains,get_deliveriesand the like go through all entries and return copies. Get them once and keep them up to date with the events. - Windows: fill them only when opening; refresh them yourself only while open, and only what changed.
- Measure your own load with
/c remote.call("utl", "perf", 600)and Factorio's time usage display (F4 →show-time-usage).
Unified Train Logistics · version / Version 0.0.25 · made with AI help, tested by Marcel / mit KI-Hilfe erstellt, von Marcel getestet · Mod portal · GitHub
🇬🇧 English
- Quick start
- Stations and roles
- Networks
- Mixed providers and job output
- How trains run
- Fuel, cleanup and depots
- Storage
- Blueprints with parameters
- Network combinator
- UTL Manager and alerts
- Settings
- Teams and surfaces
- Space elevator
- Scenarios and tips
- FAQ and troubleshooting
-
For mod authors
- Queries · Configuring · Events
- Windows and helpers
- Add-ons: roles and data · trips · rebuilding trains · windows
- Performance · Signal icons · Examples
🇩🇪 Deutsch
- Schnellstart
- Stationen und Rollen
- Netzwerke
- Gemischte Anbieter und Auftrags-Ausgabe
- Wie die Züge fahren
- Tanken, Cleanup und Depots
- Lager
- Blaupausen mit Parametern
- Netz-Kombinator
- UTL-Manager und Warnungen
- Einstellungen
- Teams und Oberflächen
- Weltraumaufzug
- Szenarien und Tipps
- Häufige Fragen und Fehlersuche
-
Für Mod-Autoren
- Abfragen · Einstellen · Ereignisse
- Fenster und Hilfen
- Add-ons: Rollen und Daten · Fahrten · Züge umbauen · Fenster
- Leistung · Signal-Symbole · Beispiele