openOMSI GitHub Discord
Plugin API reference

Docs / Plugins / Plugin API reference

Game data getters

2 min readEdit this pagedocs/PLUGIN_API.md

On this page
  1. omsi.game.queries
  2. omsi.game.query

omsi.game.query reads the same game-owned data as the vehicle scripts' getter functions, without running a script. Getter arguments keep OMSI's zero-based indices; every other list in the API starts at 1.

omsi.game.queries#

omsi.game.queries() → list of tables

Read-only game data getters: {name, args = {{name, type}, ...}, result}. Names and zero-based indices follow the M.V. getter names, but plugins read the game data directly without executing scripts. rgba means four results in the range 0–255.

Since 0.3.40.

Lua
for _, q in ipairs(omsi.game.queries()) do print(q.name, q.result) end

omsi.game.query#

omsi.game.query(name, [args], [object]) → value(s), or nil and reason

Read a getter listed by game.queries from the player's vehicle's HOF, timetable, passengers, tickets, radio, fonts or textures. Arguments are an ordered list (empty by default). No script callback is invoked. STReadPixel returns RGBA without changing the bus's drawing colour.

Supply a loaded scripted map object's id as object to read its data, including GetArrBus* on departure boards, without needing a player vehicle. Object ids can be found through map.objects_near. Without object, reads use the player's vehicle.

Unknown names, mutating operations and invalid arguments raise an error; no vehicle returns nil and a reason.

Parameters: name string; args table, optional; object integer, optional.

Since 0.3.40.

The getters game.query takes (names are matched without regard to case; arguments in this order):

Getter Arguments Result
TextLength text, font number
STReadPixel texture, x, y r, g, b, a (0-255)
STGetR texture number
STGetG texture number
STGetB texture number
STGetA texture number
GetRouteIndex code number
GetRouteTerminusIndex route number
GetTerminusCode terminus number
GetTerminusIndex code number
GetTerminusString terminus, field string
GetBusstopCount route number
GetRouteBusstopIdent route, stop string
GetBusstopIndex ident number
GetBusstopString stop, field string
GetDepotStringGlobal field string
GetTTLineString - string
GetTTDelay - number
GetTTBusstopCount - number
GetTTBusstopIndex - number
GetTTerminusIndex - number
GetTTTerminusIndex - number
GetHeightAbovePoint x, y, z number
GetHumanCountOnPathLink link number
GetTTBusstopName stop string
GetTTBusstopDep stop number
GetTTBusstopArr stop number
NrSpecRandom seed number
GetTicketName ticket string
GetTTicketName ticket string
GetTicketValue ticket number
GetHumanCountOnSeat seat number
GetArrBusLine arrival string
GetArrBusTerminus arrival string
GetArrBusTimeDiff arrival number
GetRadioName - string
GetRadioSong - string

GetFontIndex is not a getter here: it can load fonts. Commands that change or draw are not getters either.

Lua
local text = omsi.game.query("GetTerminusString", { 0, 0 })
local arrival = omsi.game.query("GetTTBusstopArr", { 0 })

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

↑↓ to move↵ to open