Docs / Plugins / Plugin API reference
Duty and timetable
On this page
- omsi.duty.active
- omsi.duty.at_stop
- omsi.duty.delay
- omsi.duty.finish
- omsi.duty.get
- omsi.duty.next_stop
- omsi.duty.set_auto_ibis
- omsi.duty.set_closed_stops
- omsi.duty.skip_stop
- omsi.duty.skip_to
- omsi.duty.start
- omsi.duty.stops
- omsi.duty.tour
- omsi.duty.trip_stops
- omsi.duty.trips
- omsi.duty.type_ibis
- omsi.timetable.buses
- omsi.timetable.lines
- omsi.timetable.stop_names
- omsi.timetable.stops
- omsi.timetable.tour
omsi.duty.* is the player's current duty (line, tour, trip, stops). omsi.timetable.* reads the whole map's timetable without taking a duty. Times are seconds since midnight of the service day and can go past 86400.
omsi.duty.active#
omsi.duty.active() → boolean
Whether the player drives a duty (a line and tour of the timetable).
Since 0.2.22.
omsi.duty.at_stop#
omsi.duty.at_stop() → boolean
Whether the bus stands at the next stop (within 25 m of it).
Since 0.2.22.
omsi.duty.delay#
omsi.duty.delay() → number or nil
Seconds the bus is late (early negative), worked out between the stops as the game's timetable does.
Since 0.2.22.
omsi.duty.finish#
omsi.duty.finish() → boolean
Gives the duty up (the bus drives on without a timetable); true when there was one.
Since 0.2.22. Permission: world_write.
omsi.duty.get#
omsi.duty.get() → table or nil
The duty now: line, tour, trip (its number in the duty, from 1), trips, trip_name, terminus, departure, arrival, stops, next_stop and previous_stop (each a stop: {number, name, id, arrival, departure, stops, x, y, z}), at_stop, trip_done, delay (seconds, late positive).
Since 0.2.22.
local d = omsi.duty.get()
if d and d.next_stop then
omsi.ui.toast(d.next_stop.name .. " " .. omsi.fmt.delay(d.delay))
endomsi.duty.next_stop#
omsi.duty.next_stop() → table or nil
The next stop of the trip (as duty.stops gives them).
Since 0.2.22.
omsi.duty.set_auto_ibis#
omsi.duty.set_auto_ibis(on) → boolean
Whether the game types the duty into the bus's IBIS by itself - line, route, destination and the stop, at Shift+U and --autostart and again as each trip begins (on as a bus is taken). Off, the driver types them, or the plugin with duty.type_ibis.
For the bus the player drives now, and while the plugin runs: when it stops or is switched off the game types the IBIS again, unless another plugin still leaves it to the driver.
Off lasts for that bus only: after a change of vehicle (the vehicle event) the game types the new one's IBIS again, so a plugin that leaves it to the driver calls duty.set_auto_ibis(false) again there. true when there is a bus.
Parameters: on bool.
Since 0.3.41. Permission: vehicle_write.
omsi.on("vehicle", function()
omsi.duty.set_auto_ibis(false) -- the driver types the IBIS
end)omsi.duty.set_closed_stops#
omsi.duty.set_closed_stops(stops, [via]) → boolean
Closes stops of the duty's route for today - a diversion, roadworks: a list of their names (on every trip of the duty), and the way round them (via). The navigator strikes them through and shows via for the next one; the bus does not call there, and the duty goes on past them without counting them missed (no stops_skipped).
Each call replaces the list (64 names at most), an empty one opens them all again; a duty taken anew (duty.start) starts with none. duty.stops marks them closed. true when there is a duty.
Parameters: stops table; via string, optional.
Since 0.3.36. Permission: world_write.
omsi.duty.set_closed_stops({ "Markt", "Rathaus" }, "via Bahnhofstraße")omsi.duty.skip_stop#
omsi.duty.skip_stop() → string or nil
Skips the next stop (the duty goes on to the one after); the name of the stop skipped.
Since 0.2.22. Permission: world_write.
omsi.duty.skip_to#
omsi.duty.skip_to(stop) → boolean
Makes stop stop (from 1) of the trip the next one, forwards or back.
Parameters: stop integer.
Since 0.2.22. Permission: world_write.
omsi.duty.start#
omsi.duty.start(line, tour, [trip], [stop]) → true, or false and the reason
Takes a duty, as the game menu's "Line and tour" does: a line and tour of timetable.lines, its trip (from 1 in the order they leave; default the first) and the stop to start at (from 1 among those the trip calls at; default the first). The bus stays where it is.
Parameters: line string; tour string; trip integer, optional; stop integer, optional.
Since 0.2.22. Permission: world_write.
local ok, why = omsi.duty.start("136", "3")
if not ok then omsi.warn(why) endomsi.duty.stops#
omsi.duty.stops() → list of tables
The stops of the trip now: {number, name, id, arrival, departure, stops, closed, passed, x, y, z} (stops false: the bus passes it; closed: closed today, duty.set_closed_stops; x, y, z where the stop's place is known; id the map's object id).
Since 0.2.22.
for _, stop in ipairs(omsi.duty.stops()) do
print(stop.name, omsi.fmt.clock(stop.departure))
endomsi.duty.tour#
omsi.duty.tour() → table or nil
The complete source tour of the selected duty, even when only one trip was selected. Same structure as timetable.tour; times align with the active duty's service day, with time_offset seconds applied to all trips and stops.
Since 0.3.40.
local tour = omsi.duty.tour()
if tour then
for _, trip in ipairs(tour.trips) do
for _, stop in ipairs(trip.stops) do
print(trip.line, trip.terminus, stop.name, stop.arrival, stop.departure)
end
end
endomsi.duty.trip_stops#
omsi.duty.trip_stops(trip) → list of tables or nil
The stops of a trip of the duty (from 1), as duty.stops gives them.
Parameters: trip integer.
Since 0.2.22.
omsi.duty.trips#
omsi.duty.trips() → list of tables
The trips of the duty: {number, name, line, terminus, departure, arrival, stops}.
Since 0.2.22.
omsi.duty.type_ibis#
omsi.duty.type_ibis() → boolean
Types the trip under way into the bus's IBIS now - line, route, destination and the stop the bus is at - as Shift+U does (bus.set_line types the line only); with duty.set_auto_ibis on, the next trips follow by themselves. true when there is a duty and a bus.
Since 0.3.41. Permission: vehicle_write.
omsi.timetable.buses#
omsi.timetable.buses() → list of tables
The timetable buses of the AI on the road: {id, line, tour, trip, terminus, departure, next_stop_id, at_stop, trip_done, delay, x, y, number}.
Since 0.2.22.
omsi.timetable.lines#
omsi.timetable.lines() → list of tables
The map's lines: {name, user_allowed, tours}, each tour {number, today, trips} (today: it runs on the game's date).
Since 0.2.22.
for _, line in ipairs(omsi.timetable.lines()) do print(line.name, #line.tours) endomsi.timetable.stop_names#
omsi.timetable.stop_names() → list of tables
The stops the timetable knows: {id, name} (id the map's object id).
Since 0.2.22.
omsi.timetable.stops#
omsi.timetable.stops(line, tour, [trip]) → list of tables
The stops of a tour's trips (or of its trip trip, from 1 in the order they leave) that the bus calls at: {trip, station, name, departure}.
Parameters: line string; tour string; trip integer, optional.
Since 0.2.22.
omsi.timetable.tour#
omsi.timetable.tour(line, tour) → table, or nil and reason
Read a full tour without taking it:
source_number- both from 1
profile_index- from 0
profilename,factor
all stops (id, name, arrival, departure, stops, optional x,y,z). Times are seconds from service-day midnight, can exceed 86400, passing stops are retained. Unknown trip references are skipped, retaining their source numbers. No AI vehicle is reserved.
Parameters: line string; tour string.
Since 0.3.40.
Something wrong or missing? Fix it on GitHub or open an issue.