openOMSI GitHub Discord

Docs / Making content / HTML textures: modern engine

Departures of a stop

1 min readEdit this pagedocs/HTMLTEXTURE_MODERN.md

omsi.getDepartures(stop) gives the departures at a bus stop for the next 2 hours, soonest first, at most 20. stop is the stop's name as in the timetable (Busstops.cfg), any letter case. Works on vehicle and scenery pages.

JavaScript
omsi.update = function () {
    var list = omsi.getDepartures('Hauptbahnhof');
    for (var i = 0; i < list.length; i++) {
        var minutes = Math.round((list[i].time - omsi.timestamp) / 60);
        console.log(list[i].line + ' ' + list[i].destination + ' in ' + minutes + ' min');
    }
};
field meaning
line the line text
destination the destination text
time departure as a timestamp, same scale as omsi.timestamp, delay included
stopsAway stops the bus still calls at up to this one, this one counted (1: this is its next stop, 0: it stands here); null while it is not on the road
load how full it is, 0..1 of its seats and standing places; null unless its passengers are simulated
delaySec how late it runs (s) once it is on the road, else null
lastTrip true for the last departure of its line at this stop today
  • The first call for a stop returns []. The game fills the stop a moment later and then calls omsi.update again, so ask inside update.
  • The game keeps the 8 stops a page asked for most recently. Asking for a ninth pushes out the one asked longest ago; asking for that one again later gives [] for a moment until it is made anew. The list is renewed about once a second.
  • Without a timetable on the map the list stays empty.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open