openOMSI GitHub Discord
Plugin API reference

Docs / Plugins / Plugin API reference

LAN games

1 min readEdit this pagedocs/PLUGIN_API.md

On this page
  1. omsi.lan.active
  2. omsi.lan.chat
  3. omsi.lan.me
  4. omsi.lan.players
  5. omsi.lan.send
  6. omsi.lan.session

omsi.lan.* reads the LAN session and sends short texts to the same plugin on the other players' games.

omsi.lan.active#

omsi.lan.active() → boolean

Whether this game is in a LAN session.

Since 0.2.22.

omsi.lan.chat#

omsi.lan.chat(text) → true, or false and the reason

Says a line in the session's chat, as the player would (every player sees it; at most one a second).

Parameters: text string.

Since 0.2.22. Permission: lan.

omsi.lan.me#

omsi.lan.me() → id, name, host

This player in the session: its id (the host is 1), its name, whether it hosts.

Since 0.2.22.

omsi.lan.players#

omsi.lan.players() → list of tables

The other players of the session: {id, name, host, bus, line, tour, x, y, z, heading, speed, on_foot, passengers}.

Since 0.2.22.

Lua
for _, p in ipairs(omsi.lan.players()) do print(p.name, p.line) end

omsi.lan.send#

omsi.lan.send(to, text) → true, or false and the reason

Sends a short text (at most 120 characters, no |) to the same plugin on another player's game (to its id; 0: every other player); it hears lan_message(from, text). A player sends at most about ten a second; a game without the plugin ignores them.

Parameters: to integer; text string.

Since 0.2.22. Permission: lan.

Lua
omsi.lan.send(0, "hello")  -- this plugin on every other player's game

omsi.lan.session#

omsi.lan.session() → table or nil

The host's name and world as it announced them on joining: {host, map, date, time, weather, season} (date is YYYY-MM-DD from that announcement; time is the live session clock in seconds since midnight, the same on the host and every client). Nothing outside a LAN session; the host alone supplies the session details, and plugins can only read them.

Since 0.2.22. Permission: lan.

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

↑↓ to move↵ to open