openOMSI GitHub Discord
Plugin API reference

Docs / Plugins / Plugin API reference

HOF depot file

1 min readEdit this pagedocs/PLUGIN_API.md

On this page
  1. omsi.hof.busstop
  2. omsi.hof.get
  3. omsi.hof.terminus

omsi.hof.* reads the player's loaded HOF depot file as a snapshot. Records keep their zero-based index for the getters; Lua lists start at 1. Snapshots are copies: changing them changes nothing in the game. Keep one and read a new one when the vehicle or its HOF changes.

omsi.hof.busstop#

omsi.hof.busstop(identifier) → table or nil

The first bus stop whose identifier exactly matches the supplied HOF stop identifier. Returns {index, identifier, strings}; index is zero-based for GetBusstopString and strings[1] is getter field 0. Returns nil without a vehicle, HOF or match.

Parameters: identifier string.

Since 0.3.40.

omsi.hof.get#

omsi.hof.get() → table or nil

A snapshot of every parsed field of the player's loaded HOF: path, name, service_trip, global_strings, string_count_terminus, string_count_busstop, termini, bus_stops, info_trips, info_busstop_lists, info_busstops. Records include their zero-based index; Lua arrays (including strings) start at 1.

Returns nil without a vehicle or HOF. No filesystem access or scripts are involved; retain the snapshot until the vehicle or HOF changes.

Since 0.3.40.

Lua
local hof = omsi.hof.get()
if hof then print(hof.name, #hof.termini, #hof.bus_stops) end

omsi.hof.terminus#

omsi.hof.terminus(identifier) → table or nil

The first terminus whose internal identifier exactly matches the supplied timetable terminus, using the same case-sensitive comparison as GetTTTerminusIndex.

Returns {index, code, identifier, terminus_stop, all_exit, strings}; index is zero-based for GetTerminusString, strings[1] is getter field 0, and terminus_stop is nil when absent. Returns nil without a vehicle, HOF or match; does not change the duty or destination.

Parameters: identifier string.

Since 0.3.40.

Lua
local tour = omsi.duty.tour()
if tour then
  for _, trip in ipairs(tour.trips) do
    local t = omsi.hof.terminus(trip.terminus)
    -- getter fields 8 and 9 are Lua elements 9 and 10
    if t then print(trip.name, t.index, t.code, t.strings[9], t.strings[10]) end
  end
end

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

↑↓ to move↵ to open