openOMSI GitHub Discord
Plugin API reference

Docs / Plugins / Plugin API reference

Cables and meshes

3 min readEdit this pagedocs/PLUGIN_API.md

On this page
  1. omsi.cable.clear
  2. omsi.cable.remove
  3. omsi.cable.set
  4. omsi.light.remove
  5. omsi.light.set
  6. omsi.mesh.clear
  7. omsi.mesh.list
  8. omsi.mesh.remove
  9. omsi.mesh.set
  10. omsi.texture.create
  11. omsi.texture.load
  12. omsi.texture.remove

omsi.cable.* draws thin tubes (cables, ropes, wires) in the 3D world, in map coordinates or attached to the bus. omsi.mesh.* draws any triangles the plugin makes: markers, signs, whole models built in code, textured with the plugin's own pictures (omsi.texture.*). omsi.light.* puts point and spot lights into the world. They need the ui permission.

omsi.cable.clear#

omsi.cable.clear() → integer

Takes every cable of the plugin away; how many went. They go by themselves when the plugin stops.

Since 0.2.22. Permission: ui.

omsi.cable.remove#

omsi.cable.remove(id) → boolean

Takes the cable id away; true when there was one.

Parameters: id string.

Since 0.2.22. Permission: ui.

omsi.cable.set#

omsi.cable.set(id, points, [options]) → boolean

Lays the cable id or moves it: a thin round tube through points (a flat list {x1, y1, z1, x2, ...} or a list of {x, y, z}, metres), lit and shaded as the scene.

options: radius (m, default 0.006), color ({r, g, b} or {r, g, b, a}, 0 to 1, default dark grey) and frame: "world" (the map's coordinates, z up; the default) or "bus" (the player's bus's model frame: x right, y forward, z up, so a rope tied to the bus moves with it as drawn).

Set it again whenever it moves; false (and the cable stays as it was) when the plugin would have more than 4096 cables, or more than 65536 points in all its cables together.

Parameters: id string; points table; options table, optional.

Since 0.2.22. Permission: ui.

Lua
omsi.cable.set("tow", { 0, 6, 0.5,  0, 10, 0.4 }, { frame = "bus", radius = 0.01 })

omsi.light.remove#

omsi.light.remove(id) → boolean

Takes light id of the plugin away.

Parameters: id string.

Since unreleased. Permission: ui.

omsi.light.set#

omsi.light.set(id, light) → true, or false and the reason

Puts light id of the plugin into the world, or changes it: {x, y, z, radius, color, intensity, direction, cone, inner, frame} - a point light, or a spot light along direction with a cone of cone degrees (full strength within inner).

frame "bus" measures the position (and direction) in the player's bus's frame, so the light moves with it. Up to 256 lights a plugin; they light the scene as the game's own lamps do.

Parameters: id string; light table.

Since unreleased. Permission: ui.

omsi.mesh.clear#

omsi.mesh.clear() → integer

Takes every mesh of the plugin away; how many there were.

Since unreleased. Permission: ui.

omsi.mesh.list#

omsi.mesh.list() → list of strings

The ids of the plugin's meshes.

Since unreleased.

omsi.mesh.remove#

omsi.mesh.remove(id) → boolean

Takes mesh id of the plugin away.

Parameters: id string.

Since unreleased. Permission: ui.

omsi.mesh.set#

omsi.mesh.set(id, mesh) → true, or false and the reason

Makes mesh id of the plugin in the world, or changes it: any triangles, lit and shaded as the scene round them.

mesh is {positions, indices, normals, uvs, color, frame, origin, rotation, two_sided}: positions a flat list {x1, y1, z1, x2, ...} (or of {x, y, z}) in metres from origin, indices three a triangle (from 0), normals and uvs one per vertex or none (the normals are then worked out), color {r, g, b[, a]} 0 to 1, frame "world" (map coordinates, the default) or "bus" (the player's bus's frame: x right, y forward, z up, moving with it), rotation {pitch, roll, heading} in degrees, texture the id of one of the plugin's textures (texture.load, texture.create).

At most 262144 vertices a mesh, 1048576 and 4096 meshes a plugin. Set it again to change it.

Parameters: id string; mesh table.

Since unreleased. Permission: ui.

omsi.texture.create#

omsi.texture.create(id, width, height, [pixels]) → true, or false and the reason

Makes texture id of the plugin from pixels: width x height RGBA, a string of bytes (4 a pixel, row by row from the top) or a list of numbers 0-255; none: white. Draw text, dials or a live map into it and show it on a mesh. Up to 4096 pixels a side and 16 million pixels a plugin.

Parameters: id string; width integer; height integer; pixels string, optional.

Since unreleased. Permission: ui.

omsi.texture.load#

omsi.texture.load(id, file) → true, or false and the reason

Makes texture id of the plugin from a picture file of its own folder (or its data folder: data/...): png, jpg, bmp, tga or dds. Its meshes draw with it by texture = id.

Parameters: id string; file string.

Since unreleased. Permission: ui.

omsi.texture.remove#

omsi.texture.remove(id) → boolean

Takes texture id of the plugin away (its meshes are drawn untextured).

Parameters: id string.

Since unreleased. Permission: ui.

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

↑↓ to move↵ to open