openOMSI GitHub Discord
Plugin API reference

Docs / Plugins / Plugin API reference

Camera

2 min readEdit this pagedocs/PLUGIN_API.md

On this page
  1. omsi.camera.fov
  2. omsi.camera.get
  3. omsi.camera.in_cab
  4. omsi.camera.look
  5. omsi.camera.orientation
  6. omsi.camera.position
  7. omsi.camera.project
  8. omsi.camera.set_free
  9. omsi.camera.set_view
  10. omsi.camera.set_zoom
  11. omsi.camera.view

omsi.camera.* reads the camera and moves it. Changing it needs the camera permission.

omsi.camera.fov#

omsi.camera.fov() → number or nil

Its vertical field of view, degrees.

Since 0.2.22.

omsi.camera.get#

omsi.camera.get() → table or nil

The camera: {view, x, y, z, yaw, pitch, roll, fov, in_cab, zoom, look_yaw, look_pitch, width, height} - map metres, degrees (yaw clockwise from north, pitch up positive), the vertical field of view, the picture's pixels.

Since 0.2.22.

omsi.camera.in_cab#

omsi.camera.in_cab() → boolean

Whether the camera is in the player's own bus (driver or passenger view).

Since 0.2.22.

omsi.camera.look#

omsi.camera.look(yaw, pitch) → boolean

Turns the head (driver, passenger view) or swings the outside camera round the bus: degrees from straight ahead.

Parameters: yaw number; pitch number.

Since 0.2.22. Permission: camera.

omsi.camera.orientation#

omsi.camera.orientation() → yaw, pitch, roll

Where it looks, degrees.

Since 0.2.22.

omsi.camera.position#

omsi.camera.position() → x, y, z

Where the camera is (map metres).

Since 0.2.22.

omsi.camera.project#

omsi.camera.project(x, y, z) → screen_x, screen_y

Where a map point is seen on the screen, in the panels' pixels (as ui.screen measures them); nothing when it is behind the camera. For labels over buses, stops, people.

Parameters: x number; y number; z number.

Since 0.2.22.

Lua
local sx, sy = omsi.camera.project(x, y, z + 3)
if sx then -- the point is on screen
end

omsi.camera.set_free#

omsi.camera.set_free(x, y, z, [yaw], [pitch]) → boolean

Puts the free camera at a map point looking along yaw and pitch (degrees); the view becomes "free" (the player moves it on from there).

Parameters: x number; y number; z number; yaw number, optional; pitch number, optional.

Since 0.2.22. Permission: camera.

omsi.camera.set_view#

omsi.camera.set_view(view) → boolean

Switches the view: "driver", "pax", "outside", "map" (the free camera above the bus), "ego" (walking), or a view_* action of keyboard.cfg.

Parameters: view string.

Since 0.2.22. Permission: camera.

Lua
omsi.camera.set_view("outside")

omsi.camera.set_zoom#

omsi.camera.set_zoom(zoom) → boolean

The zoom of the view now (its field of view times this, 0.2 to 3).

Parameters: zoom number.

Since 0.2.22. Permission: camera.

omsi.camera.view#

omsi.camera.view() → string or nil

The view: "driver", "pax", "outside", "free" or "foot".

Since 0.2.22.

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

↑↓ to move↵ to open