Docs / Plugins / Lua plugins
Your first plugin
Create plugins/hello.lua next to the game:
-- plugins/hello.lua
omsi.on("vehicle", function(name)
omsi.message("Good morning! Today you drive the " .. name, 6)
end)
omsi.every(1, function()
local kmh = omsi.var("Velocity")
if kmh and kmh > 50 then
omsi.message(string.format("Slow down: %.0f km/h", kmh), 1)
end
end)Start a map with a bus: the greeting shows up on the screen, and above 50 km/h the warning. Edit the file while the game runs and save it - the plugin is loaded again within a second ("Lua plugin hello reloaded").
Something wrong or missing? Fix it on GitHub or open an issue.