Docs / Plugins / Writing plugins
Scripts in a vehicle
A vehicle can carry its own scripts, written in Lua or compiled to an .oop, so a mod needs no plugin installed by the player. Name them in the vehicle's .bus or .ovh file, relative to the vehicle's folder:
[vehicle_script]
scripts/cab.lua
[vehicle_script]
scripts/ibis.oopThe scripts start when the vehicle becomes the player's and stop when the player changes to another vehicle or none. They see the same omsi.* API as any plugin, and omsi.var reads their own bus. In the log they are named vehicle:<file>.
A vehicle is content from anywhere, so its scripts get only these permissions: ui, storage, vehicle_write and audio. The world, the traffic, the camera, the LAN, UDP, WebSocket feeds and native programs are only for the player's own plugins. An .oop that declares more keeps only these four.
OMSI 2 ignores the keyword and runs the vehicle's .osc scripts as always. A vehicle can have both.
Scenery objects can also have Lua scripts, named with [lua_script] in the .sco file. See Scripts of map objects.
Something wrong or missing? Fix it on GitHub or open an issue.