openOMSI GitHub Discord

Docs / Plugins / Lua plugins

Your first plugin

1 min readEdit this pagedocs/PLUGINS.md

Create plugins/hello.lua next to the game:

Lua
-- 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.

↑↓ to move↵ to open