openOMSI GitHub Discord

Docs / Plugins / Lua plugins

Safety and errors

1 min readEdit this pagedocs/PLUGINS.md

A Lua plugin gets Lua 5.4 with the safe libraries only: string, table, math, utf8, coroutine, require for its own folder, and os.clock/time/date/difftime.

There is no io, no os.execute (not through require("os") either), no C modules, no dofile, and no binary chunks anywhere: plugin files, modules and load read text only (Lua has no checker for compiled code), and string.dump gives no code.

A plugin reads and writes files only in its own data folder (.. and absolute paths are refused) and reads its own folder; it cannot reach the network either: omsi.send talks only to programs on this computer, and only to ports from 1024 up. It holds at most 256 MB of memory.

  • An error in a handler is written to game.log and shown on the screen; the other plugins and the game carry on. After 10 errors the plugin is switched off until you change its file or restart the game.
  • A call into the plugin that runs longer than 50 ms (an endless loop) is stopped and the plugin switched off, with a line in game.log; loading it may take a second.
  • A file that does not compile is left out, with the Lua error in game.log.

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

↑↓ to move↵ to open