System Macros are a set of pre-defined procedures which can be called from scripts in order to interact with data beyond the scripting engine, for example reading data from HOF files.
System Macros are called with (M.V.example); like Operators, most consume operands from the float and/or string stacks. For the purpose of these descriptions the operands are labelled f0–f7 for the float stack and $0–$7 for the string stack. Because the stacks are independent, string operands can come before, after or intermingled amongst float operands.
Returns the Line Number (e.g. "92E") for the Arrival Index-th (zero-based) bus to arrive at the bus stop. The sceneryobject must be parented to a bus stop cube to get a result returned.
E.g.: 1 (M.V.GetArrBusLine) returns the route number of the 2nd bus due to arrive at the bus stop.
Returns the Destination (e.g. "Stadtgrenze") for the Arrival Index-th (zero-based) bus to arrive at the bus stop. The sceneryobject must be parented to a bus stop cube to get a result returned.
E.g.: 1 (M.V.GetArrBusTerminus) returns the terminus of the 2nd bus due to arrive at the bus stop.
Returns the Time until arrival in seconds for the Arrival Index-th (zero-based) bus to arrive at the bus stop. The sceneryobject must be parented to a bus stop cube to get a result returned.
E.g.: 1 (M.V.GetArrBusTimeDiff) returns the number of seconds until the 2nd bus due to arrive at the bus stop arrives.
System Macros for Vehicles
These are declared in /program/callbacklist_roadvehicle.txt.
Returns the terminus index of the specified route in the HOF file—the HOF file creator can put any integer here, so a terminus with this index is not guaranteed to exist in the HOF file.
Returns the Route-Busstop Index-th (zero-based) entry in the bus stop list for the specified route. While the implication is that this is a Busstop Ident, and the default IBIS script passes the return value straight into GetBusstopIndex, this can be any arbitrary string—get creative!
Returns the terminus index for the active timetable. The map creator can put any integer here, so a terminus with this index is not guaranteed to exist in the HOF file.
Returns the index (zero-based) of the current stop in the active timetable (e.g. 0 when driving from the lay-over point to the starting bus stop, incrementing each time the bus stop changes in the red line until 1 less than GetTTBusstopCount).
Returns the difference between where the bus is and where OMSI thinks the bus should be according to the timetable in seconds, e.g. -1.3 indicates the bus is 1.3 seconds ahead of schedule.
Return the arrival or departure times for the specified bus stop in the active timetable. These should be seconds since midnight, like the system variable Time.
Returns a pseudo-random value (0–1?) based on the fleet number and Seed—the same combination of fleet number and seed will result in the same random value.
This is intended to be used to simulate random variations across a fleet of vehicles—each vehicle will have different but consistent variations.
Returns the distance (metres) from the point (X, Y, Z) (metres, relative to vehicle origin) that a ray cast along the vehicle's -Z axis (down, but relative to the vehicle not gravity) would intersect the ground (terrain, road or pavement).
Particularly useful for scripting wheelchair ramps/lifts to stop when touching the ground, like the one on the default EN/GN92. Could also be used to simulate the door sill coming to rest on a kerb when kneeling (bonus points if the door jams because the body is being twisted! 😈).
Initialises the script-texture (replaces any existing data with a black bitmap rectangle matching the dimensions of the script-texture). Initialising a script-texture should be done irregularly to avoid slow downs.
After initialisation, the script-texture will be unlocked, regardless of whether it was locked beforehand.
Locks the script-texture, allowing your script to draw to the script-texture and preventing OMSI from displaying the changes while the script-texture is locked.
Creates mipmaps for the script-texture. If this is not done, the texture gets blurry in the distance. Filtering a script-texture should be done irregularly to avoid slow downs.
STFilter can only be performed on an unlocked script-texture.
Sets the colour to be used for drawing operations on the script-texture. The value for each channel should be an integer between 0 and 255 (inclusive).
Draws a filled rectangle with top-left pixel (X1, Y1) and bottom-right pixel (X2, Y2) in the drawing colour. Bottom-right pixel is inclusive, so 0 0 1 1 will result in a 2 × 2 square.
Writes text with top-left pixel (X, Y) in the given font.
Font Index can be found with GetFontIndex.
If Full Colour is true the font's colour bitmap will be used for the colour channels, otherwise a rectangle is drawn in the drawing colour. The alpha channel is always taken from the font's alpha bitmap.
Letter Spacing specifies a number of additional pixels to insert between each character.
Replaces the script-texture bitmap with the given texture file. If the texture file does not exist, the script-texture is unchanged.
Loading a DXT-compressed DDS image works fine, but any attempts to draw onto the image will appear corrupted.
If drawing to the script texture in the same frame as a texture is loaded, STLock should be run afterSTLoadTex, otherwise the drawing actions may be run before the texture has finished loading, causing glitches and crashes.