Repository navigation
API Examples
🇩🇪 Deutsche Version · ⬅ For mod authors
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)local mapping = stack.create_blueprint({ surface = surface, force = force, area = area })
remote.call("utl", "tag_blueprint", stack, mapping, surface)local function listen()
local ids = remote.call("utl", "get_event_ids")
script.on_event(ids.on_delivery_completed, function(event)
storage.done = (storage.done or 0) + 1
end)
end
script.on_init(listen)
script.on_load(listen)Two own roles: a shunting depot whose trains belong to the add-on, and a siding where UTL dispatches nothing. When a shunting locomotive is free, the add-on sends it to the siding and back. What happens there (parking wagons, coupling …) would be the add-on's own logic.
control.lua of the mod shunting-example (dependency on UTLogistics):
local MOD = "shunting-example"
local function register()
remote.call("utl", "register_role", { mod = MOD, name = "depot", caption = "Shunting depot",
base = "depot", own_trains = true })
remote.call("utl", "register_role", { mod = MOD, name = "siding", caption = "Siding" })
end
local function listen()
local ids = remote.call("utl", "get_event_ids")
-- shunting locomotive free: send it to the first siding
script.on_event(ids.on_train_idle, function(event)
if event.role ~= MOD .. "/depot" then return end
local sidings = remote.call("utl", "get_stations", { addon_role = MOD .. "/siding" })
if not sidings[1] then return end
remote.call("utl", "send_job", event.train_id, MOD, {
{ station = sidings[1].unit, wait = { { type = "time", ticks = 30 * 60 } } },
})
end)
script.on_event(ids.on_job_finished, function(event)
if event.mod == MOD then game.print("Shunting trip " .. event.job_id .. " done") end
end)
end
script.on_init(function() register() listen() end)
script.on_configuration_changed(register)
script.on_load(listen)In the game: build two UTL train stops, tick "Shunting depot" on one and "Siding" on the other in the station window, and put a locomotive with the shunting depot in its schedule on the track.
More: roles and data, trips, rebuilding trains, windows.
Unified Train Logistics · version / Version 0.0.27 · 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