Global Functions and Variables

global functions

table getPerformanceMetrics()

Returns a table of time values that measures the time of different systems to get the performance.

Returns:table of performance Metrics

Member Variables:

Type Name Describtion
float framePresentDelay time mainthread is waiting for gpu finish the last frame
float cpuUpdateUI time used to update the UI
float sfxDelay time used to update sound subsystem
float luaDelay time to update Lua
float cpuPreRender //TODO
float cpuRender time of default renderPassManager. No include pre/post renders
float cpuPostRender //TODO

Example: This exaple prints all performance metrics values into the console.

local a = getPerformanceMetrics() -- Gets the table
print(a.framePresentDelay) -- prints f.e. 0.080227814614773
print(a.cpuUpdateUI) -- prints f.e. 0.39603367447853
print(a.sfxDelay) -- prints f.e. 0.028809079900384
print(a.luaDelay) -- prints f.e 0.43979430198669
print(a.cpuPreRender) -- prints f.e 1.3886705636978
print(a.cpuRender) -- prints f.e 3.3520641326904
print(a.cpuPostRender) -- prints f.e 0.017504250630736
string getHardwareID()

Gets your Hardware-ID

Returns:the Hardwareid of your Computer

Example: This Example prints your Hardware-ID into the console.

print(getHardwareID()) -- prints for example 76552257C363E39173F2B3E2CD05F1199FD1
bool openWebBrowser(char webAddress)

Parameters:

  • char webAddress: The Webadress, that should be opened in the browser.
Returns:(bool) if the browser was opened successfully

Example: Opens the Browser with the Domain “www.beamng.com”

print(openWebBrowser("www.beamng.com")) -- prints true, because the Webbrowser was opened successfully
bool setClipboard(char text)

Copies a string to the cache of the computer

Example: Copies “This is a test-Set” to your Clipboard

setClipboard("This is a test-Set") -- prints true, because the Webbrowser was opened succesfully
print("Setted to Clipboard complete")
createScreenshot(char file, char format, int tileCount, int tileOverlap)

Creates a Screenshot and saves it as a File.

Parameters:

  • char file: the name of the file
  • char format: in png or jpg
  • char tileCount: //TODO
  • char tileOverlap: //TODO

Example: This Example creates a new Screenshot in the folder “screenshots” with the name “screenshot”

local screenShot = createScreenshot("screenshots/screenshot", "jpg", 1, 1)
VirtualInputManager getVirtualInputManager()

Gets the Input Manager of the Game

Returns:(VirtualInputManager) The input-Manager

Example: Resets the Input-Devices:

getVirtualInputManager():resetDevices()
showCefDevConsole(bool state)

This Function opens/close the Cef-Development Console

Example: just opens the CefDevConsole

Parameters:

  • bool state: “true” opens the console, “false” closes it
showCefDevConsole(true)
compileCollada(char src, char dst, char dataFilename)
shutdown(int val)

Function to shut down the Game

Parameters:

  • int val: Time that wait until the Game shuts down.

Example: Shut down the Game

shutdown(5) -- Shutdown in 5 Seconds!
forceShutdown(int val)

Function to Force shut down the Game

Parameters:

  • int val: Time that wait until the Game shuts down.

Example: Shut down the Game

forceShutdown(5) -- Force-Shutdown in 5 Seconds!
alertOK(char title, char msg)

Sends an alert in this Style:

width:120pt

Parameters:

  • char title: The title of the alert
  • char msg: The message, thats in the alert.

Example: This Example sends an alert

alertOK("This is a title", "This is a Message")
setCEFFocus(bool v)

Parameters:

  • bool v: true to focus CEF, false to defocus CEF

Example: focus the CEF

setCEFFocus(true) -- Focus the CEF
bool getCEFFocusMouse()

Gets the mouse-Focus

Returns:true if the Mouse is fucused, false if mouse isn’t focused

Example: Checks, if the mouse is focused

print(getCEFFocusMouse())
getCEFFocusMouseLastTimeMs()

Gets the last mouse-Focus

Returns:(timestamp) since system was started

Example: Checks, when the mouse focused the last time

print(getCEFFocusMouseLastTimeMs()) -- prints 362160140
bool getCEFFocusKeyboard()

Checks, if the Keyboard is focused on CEF

Returns:(bool) true if the Keyboard is focused on CEF, else false

Example: Checks if the Keyboard is focused on CEF

print(getCEFFocusKeyboard())
timestamp getMovedMouseLastTimeMs()

Gets the timestamp where the mouse moved the last time.

Returns:the Time when the Mouse moved the last time

Example: Prints out the time, when the mouse was moved the last time

print(getMovedMouseLastTimeMs())
number dot(Point3F a, Point3F b)

Calculates the scalar product of two points

Parameters:

  • Point3F a: first point to get scalar product from
  • Point3F b: second point to get scalar product from
Returns:(number) the scalar product of two points

Example: Calculates the scalar product of two Point3F

print(dot(Point3F(3,2,1), Point3F(100,20,30))) -- prints 370 (3*100 + 2*20 + 1*30)
getTSVar(char name)

Gets a Torque-Script Variable

Parameters:

  • char name: The name of the Torque-Script-Variable
Returns:() The variable

Example:

print(getTSVar("$pref::Video::displayDevice")) --prints f.e. D3D11
setTSVar(char name, char value)

Parameters:

  • char name: The name of the Torque-Script-Index
  • char value: The new value of the Variable

Example: Sets displayDevice to “DDDDD” and prints it then in Console

setTSVar("$pref::Video::displayDevice", "DDDDD")
print(getTSVar("$pref::Video::displayDevice"))
GameBase getCamera()

Returns the camera

Returns:(GameBase) returns the Camera-Object.

Example: Gets the Camera and prints its position.

print(getCamera():getPosition()) --prints the Cameraposition: f.e. 18.0195, -13.8007, 9.42402
Point3F getCameraPosition()

Gets the Camera Position.

Returns:Point3F: Position of the Camera
print(getCameraPosition()) --prints the Cameraposition: f.e. 18.0195, -13.8007, 9.42402
MatrixF getCameraTransform()

Gets the Transform of the Camera

Returns:MatrixF: The Transform

Example This Example just prints the Transform of the Camera into the console.

print(getCameraTransform())
-- prints for example:
--  -0.87066, -0.463119, 18.0195
--  0.986168, 0.146333, 0.077837, -13.8007
--  0, -0.469615, 0.882871, 9.42402
QuatF getCameraQuat()

Returns the Quat from Camera

Returns:(QuatF) The Quat of Camera
print(getCameraQuat()) -- prints for example: 0.184758, 0.156297, -0.626656, 0.740768
setCameraPosRot(float px, float py, float pz, float rx, float ry, float rz, float rw)

Rotation are Quaternion (What that is, you can read f.e. here: click)

Parameters:

  • float px: Position on X axis
  • float py: Position on Y axis
  • float pz: Position on Z axis
  • float rx: Rotation on X axis
  • float ry: Rotation on Y axis
  • float rz: Rotation on Z axis
  • float rw: Rotation on W

Example: Sets the Camera Position to 18.0195, -13.8007, 9.42402 and Rotation to -0.184758, 0.156297, -0.626656, 0.740768

setCameraPosRot( 18.0195, -13.8007, 9.42402, -0.184758, 0.156297, -0.626656, 0.740768)

global variables

GameEngineLua Lua

The global lua Variable. You can find functions implemented for this object here: GameEngineLua

Usage:

lua:getSelectedLanguage()
SteamIntegration Steam

Example:

print(Steam.language)
BeamEngine be

The global BeamEngine Object. To find a list of functions of this element here BeamEngine

Usage:

be:getPlayerVehicle(0) -- Gets the Player Car
BNGBase::FS::IFileSystem FS

The object of the file system.

Usage:

fs:fileSize("testfile.lua") -- Gets the file size of a file.
DebugDrawer debugDrawer

The Object for debugging Stuff like Lines, Texts or Boxes.

Usage:

debugDrawer:drawLine(Point3F(1,2,3), Point3F(3,2,1), ColorF(1,1,1,1)) -- Will draw a line
string cachepath

(“cache.” BEAMNG_VERSION_TYPEB “/”) cache.0.10.0.1/

string beamng_versionb

0.10.0.1

string beamng_versiond

0.10.0.1.4385

string beamng_version

0.10.0.1.4385

string beamng_windowtitle

BeamNG.drive - 0.10.0.1.4385 - RELEASE - x64

string beamng_buildinfo

buildbot build 4385 on winbuildbot - date - time

string beamng_arch

x64

string beamng_buildnumber

4385

string beamng_appname

BeamNG.drive

int COMMAND_CONTEXT_TS

ActionMap::COMMAND_CONTEXT_TS

int COMMAND_CONTEXT_UIJS

ActionMap::COMMAND_CONTEXT_UIJS

int COMMAND_CONTEXT_VLUA

ActionMap::COMMAND_CONTEXT_VLUA

int COMMAND_CONTEXT_ELUA

ActionMap::COMMAND_CONTEXT_ELUA

int COMMAND_CONTEXT_TLUA

ActionMap::COMMAND_CONTEXT_TLUA

int UI_TEXTURE_USAGE_ONCE

BEAMNGCEF::UI_TEXTURE_USAGE_ONCE

int UI_TEXTURE_USAGE_AUTOMATIC

BEAMNGCEF::UI_TEXTURE_USAGE_AUTOMATIC

int UI_TEXTURE_USAGE_MANUAL

BEAMNGCEF::UI_TEXTURE_USAGE_MANUAL