openOMSI GitHub Discord

Docs / Reference / Content formats

Script textures and the IBIS callbacks

3 min readEdit this pagedocs/FORMATS.md

[scripttexture] w h (model.cfg) declares an RGBA image per index, [useScriptTexture] n puts it on a material, [matl_transmap] \S:n uses its alpha as transparency map.

[htmltexture] w h file declares a page the engine draws (see HTMLTEXTURE.md), lit on the line after the page's path makes it a surface - shaded by the world's light as every other material is, on every slot that shows the page, a scenery object's or a vehicle's - where a page is a display, drawn unlit at its own brightness, by default.

An openOMSI extension, Omsi.exe draws such a slot unlit either way.

[navigatortexture] w h [variable] [mapScale] [fixedNorth] [noNavUI] [navCenter] [showHistory] declares a screen the game's navigator draws its small map on, while the optional variable is not 0 (see NAVIGATORTEXTURE.md), [useNavigatorTexture] n puts the n-th on a material. Also an openOMSI extension. The scripts draw with (M.V.ST…) callbacks, arguments pushed in order (index first):

STNewTex(i) STLock(i)
STUnlock(i)
upload
STFilter(i) STSetColor(i, a, r, g, b) STDrawPixel(i, x, y) STDrawRect(i, x1, y1, x2, y2)
STTextOut(i, x, y, font, mode, letter-spacing, "text")
mode bit 0: colour from the font's colour bitmap, else the STSetColor colour; alpha from the font's mask; mode & 3 == 2 writes only covered pixels, other modes the whole glyph cell

STReadPixel(i, x, y) + STGetR/G/B/A(0), STLoadTex("path", i) (pushes nothing - OMSI 0x7bba4e only logs a missing file; the path is relative to the object's Texture folder, then to the global Texture, so the Krüger matrix's ..\..\Anzeigen\Krueger\x.bmp is Vehicles\Anzeigen\Krueger\x.bmp), STCopyColor(a, b).

GetFontIndex("name") registers an .oft font, answers -1 for a font that does not exist (the chura matrix falls back from missing custom fonts with 1 + 31416 * l1 1 + max 31415 % 1 -, which only works for -1), fonts are looked up by [newfont] name in every content root's Fonts. openOMSI draws a missing weight with another one of the same family, size ("churafont++ Numeric 26x11 Bold" → "churafont++ Numeric 26x11"; the Citaro pack asks for weights it never shipped and lost its line number).

TextLength(font, "text") = drawn width (glyph advance x1−x0 plus the font gap). A work texture keeps its picture in the colour channels with alpha 0 (the Krüger matrix draws STSetColor(0, 0, 255, 0, 0)), the LED textures in alpha only ([matl_transmap] \S:n, one texture per LED colour).

Glyph pixels of an .oft [char] c x0 x1 y sit in columns x0..x1 (x1 exclusive as drawn). In colour mode a glyph pixel takes the colour bitmap's pixel at the same row, column as its alpha pixel (0x5d67bc), whatever size the colour bitmap has: often a small swatch of one colour (stock EFADfont.bmp, 128×128 under a 128×200 alpha).

For a row past the colour bitmap's height Omsi.exe's TBitmap.ScanLine raises a range error (0x4763b0), the text stops being drawn there, a column past its width reads into the neighbouring scanline's bytes. openOMSI repeats the colour bitmap in both cases instead. NrSpecRandom(seed) = stable pseudo random in [0, 1).

Depot (.hof) callbacks: GetRouteIndex(code) (code = line×100 + route → [infosystem_trip] index), GetRouteTerminusIndex(route), GetTerminusCode(idx), GetTerminusIndex(code), GetTerminusString(idx, n), GetBusstopCount(route), GetRouteBusstopIdent(route, k), GetBusstopIndex("ident"), GetBusstopString(idx, n), GetDepotStringGlobal(n). openOMSI adds GetRadioName and GetRadioSong (no arguments, a string each): the bus radio's station and title, empty while it is off.

[addterminus]/[addterminus_allexit] records are code, ident, then stringcount_terminus strings (no separate station line in any shipped file).

AI buses get their destination the original way: string SetLineTo + AI_target_index (terminus index) and the ai_scheduled_settarget trigger - and, as every trip a bus starts calls TRoadVehicleInst.virtual_10, also when the depot file has no row for the trip's terminus or the group names no depot file at all (AI_target_index stays as it was).

Depot callbacks with index -1 (what the lookups answer for an unknown code) return "" / -1, never entry 0. A depot file belongs to a map: when the bus folder has none of the name the map's ailists.cfg wants (a mod bus brings only its own map's), openOMSI takes it from another vehicle folder (omsi_vehicle::hof::depot_anywhere);

a bus of a plain [aigroup_2] pool, whose group names no depot, takes the map's depot of its folder where it has one, else the folder's first (schedule::pool_depot, Omsi.exe's selected-hof index 0).

The FloFix "Atron" IBIS of many mods starts in a PIN mode (IBIS_mode 10) and wants the PIN constant of its constfile typed and confirmed before the mode keys work.

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

↑↓ to move↵ to open