Lua API

Overview

BeamNG.tech has some features that are not neccessarily part of the game. While the description of the Lua modules can be found elsewhere, this page focuses on documenting the C++ Lua api by showing function usage on the Lua side.

Module Engine

These are functions that are added to the existing Engine module for the BeamNG.tech version.

Member functions


Engine.getColorBufferBase64(width, height)

Getting color buffer from last render.

Args:

width(int): image width

height(int): image height

Returns: table

pixelsBase64(string): image, Base64 encoded

width(int): image width

height(int): image height


Engine.getDepthBufferBase64(width, height)

Gets depth buffer of last render.

Args:

width(int): image width

height(int): image height

Returns: table

pixelsBase64(string): image, Base64 encoded

width(int): image width

height(int): image height


Engine.openShmem(shmemName, size)

Opens shared memory handle with the given amount of bytes.

Args:

shmemName(string): name/id of the shared memory

size(int): size of the data to be shared

Returns: nil


Engine.closeShmem(shmemName)

Close previously opened shared memory handle.

Args:

shmemName(string): name/id of the shared memory handle

Returns: nil


Engine.getUltrasonicDistanceMeasurement(pos, rot, s, fov, nearFarPlanes)

Simulation of ultrasonic sensor, based on the depth image, thus the parameters that are similar to function calls rendering images. Warning: Although the function arguments won’t change, the implementation is subject to future change!

Args:

pos(Point3F): sensor position in the map

rot(QuatF): sensor orientation (quaternion)

s(Point2F): size

fov(float): horizontal field of view

nearFarPlanes(Point2F): defining the closest and furthest point to be rendered

Returns: float (distance measurement)

Last modified: May 20, 2024

Any further questions?

Join our discord
Our documentation is currently incomplete and undergoing active development. If you have any questions or feedback, please visit this forum thread.