Docs / Plugins / Plugin API reference
The plugin itself
On this page
- omsi.plugin.broadcast
- omsi.plugin.disable
- omsi.plugin.errors
- omsi.plugin.files
- omsi.plugin.full_access
- omsi.plugin.list
- omsi.plugin.name
- omsi.plugin.permissions
- omsi.plugin.read
- omsi.plugin.request_full_access
- omsi.plugin.send
- omsi.plugin.set_setting
- omsi.plugin.setting
- omsi.plugin.settings
- omsi.plugin.show_settings
omsi.plugin.* is about the plugin: its name, files, settings, permissions, and messages to other plugins.
omsi.plugin.broadcast#
omsi.plugin.broadcast(topic, [data]) → nil
Sends a message to every other plugin loaded.
Parameters: topic string; data any, optional.
Since 0.2.22.
omsi.plugin.broadcast("delay", omsi.duty.delay())omsi.plugin.disable#
omsi.plugin.disable([reason]) → nil
Switches the plugin off until its file changes or the game starts again (its stop comes).
Parameters: reason string, optional.
Since 0.2.22.
omsi.plugin.errors#
omsi.plugin.errors() → integer
How many errors the plugin had (at 10 it is switched off).
Since 0.2.22.
omsi.plugin.files#
omsi.plugin.files([dir]) → list of tables
The files of the plugin's own folder (or a folder in it): {name, dir, size}.
Parameters: dir string, optional.
Since 0.2.22.
omsi.plugin.full_access#
omsi.plugin.full_access() → {has, status, fingerprint}
Whether the plugin has full access, and what became of its question: status is empty (it did not ask), granted, dev, asked, denied, refused or error; fingerprint names the build of its code the player is asked about.
Since unreleased.
omsi.plugin.list#
omsi.plugin.list() → list of strings
The names of the plugins loaded, this one too.
Since 0.2.22.
omsi.plugin.name#
omsi.plugin.name() → string
The plugin's name: its file's, or its folder's for a main.lua.
Since 0.2.22.
omsi.plugin.permissions#
omsi.plugin.permissions() → list of strings
The permissions the plugin has (native process access additionally requires player opt-in).
Since 0.2.22.
omsi.plugin.read#
omsi.plugin.read(path) → text, or nil and the reason
A file of the plugin's own folder (a table of stops, a translation): read only, relative to the folder.
Parameters: path string.
Since 0.2.22.
omsi.plugin.request_full_access#
omsi.plugin.request_full_access() → true, or false and why (asked, denied, refused, not_allowed)
Asks the player for full access to the computer and the game (the native permission): the game asks in its own window, and the plugin starts again with full access once the player allows it. A plugin that knows it needs it can declare it instead, with a --@full_access line among its first lines (an .oop: the native permission). A vehicle's or a scenery object's script can never have it.
Since unreleased.
omsi.plugin.send#
omsi.plugin.send(to, topic, [data]) → nil
Sends a message to another plugin (by its name): it hears message(from, topic, data) in its next frame. The data is numbers, texts, booleans or tables of them.
Parameters: to string; topic string; data any, optional.
Since 0.2.22.
omsi.plugin.send("dispatcher", "delay", omsi.duty.delay())omsi.plugin.set_setting#
omsi.plugin.set_setting(key, value) → boolean
Changes a setting (held to its range; saved); true when it took the value.
Parameters: key string; value any.
Since 0.2.22.
omsi.plugin.setting#
omsi.plugin.setting(key) → any
A setting's value (nil: no such setting).
Parameters: key string.
Since 0.2.22.
omsi.plugin.settings#
omsi.plugin.settings(settings, [title]) → table
Declares the plugin's settings: a list of {key, type, label, default} with type "bool", "number" (min, max, step), "text" or "choice" (choices, a list of texts). The values the player chose before come back (as a table key -> value); the game makes a settings panel of them (plugin.show_settings), saves them in the data folder and sends setting(key, value) when one changes.
Parameters: settings table; title string, optional.
Since 0.2.22.
local s = omsi.plugin.settings({
{ key = "volume", type = "number", label = "Volume", default = 50, min = 0, max = 100, step = 5 },
{ key = "unit", type = "choice", label = "Speed in", choices = { "km/h", "mph" }, default = "km/h" },
}, "My plugin")
print(s.volume, s.unit)omsi.plugin.show_settings#
omsi.plugin.show_settings([on]) → boolean
Shows the plugin's settings panel (or hides it with false); it can be dragged and closed while the panels have the mouse (ui.focus). false when the plugin declared no settings.
Parameters: on bool, optional.
Since 0.2.22. Permission: ui.
Something wrong or missing? Fix it on GitHub or open an issue.