Lua Console

You can run Bin64/console.x64.exe as nice little (interactive) lua console.

Command line arguments

console.x64.exe cmd <lua string to execute>
console.x64.exe <lua file to execute>

For example to execute a lua string:

console.x64.exe cmd "print(1+1)"

For example to execute a lua file:

console.x64.exe test.lua

For an interactive shell start without arguments:

console.x64.exe

Below is a short documentation of its very simplistic API

BeamNG console Lua API Documentation

Classes

HighPerfTimer

High-performance timer for accurate time measurements.

local timer = HighPerfTimer()

Methods

  • reset() - Resets the timer to zero
  • elapsed() - Returns elapsed time in seconds since creation or last reset
  • stopAndReset() - Returns elapsed time and resets timer
  • stop() - Alias for elapsed() (deprecated)

BeamEngine

Main engine interface.

Methods

  • update(dtReal, dtSim) - Updates the engine simulation
  • spawnObject2(...) - Spawns an object in the simulation
  • deleteAllObjects() - Removes all objects from the simulation
  • setDynamicCollisionEnabled(enabled) - Enables/disables dynamic collision
  • instabilityDetected() - Checks if instability was detected in simulation

BeamObject

Represents a physical object in the simulation.

Methods

  • getNodeCount() - Returns the number of nodes in the object
  • getBeamCount() - Returns the number of beams in the object

VFS

Virtual file system interface.

the VFS can be accessed with the global variable FS

Methods

  • fileSize(filename) - Returns size of file in bytes
  • fileExists(filename) - Checks if file exists
  • directoryExists(directory) - Checks if directory exists
  • getFileRealPath(virtualPath) - Gets real filesystem path from virtual path
  • getGamePath() - Gets root game path
  • openFile(filename, mode) - Opens a file
  • copyFile(src, dst) - Copies a file
  • directoryCreate(name, recursive) - Creates a directory
  • findFiles(path, pattern, recursiveLevels, multiMatch, includeDirs) - Finds files matching pattern
  • hashFile(filename) - Gets file hash
  • hashFileSHA1(filename) - Gets file SHA1 hash
  • stat(filename) - Gets file stats
  • removeFile(filename) - Deletes a file
  • renameFile(oldName, newName) - Renames a file
  • mount(source, target, priority) - Mounts a directory or archive
  • mountList(mountList) - Mounts multiple paths
  • unmount(path) - Unmounts a path
  • isMounted(path) - Checks if path is mounted

Global Functions

  • initBeamEngine(steps) - Initializes the BeamNG engine
  • destroyBeamEngine() - Shuts down the BeamNG engine
  • reloadLua() - Reloads the Lua environment
  • log(level, origin, msg) - Logs a message
    • level: Log level (I=Info, W=Warning, E=Error, D=Debug)
    • origin: Source of the log
    • msg: Message to log
  • updateLuaCore() - Updates the Lua core system
  • profilerPushEvent(name) - Starts profiling an event
  • profilerPopEvent() - Ends profiling the current event
  • setPowerPlanMaxPerformance() - Sets system power plan to maximum performance
  • restorePowerPlan() - Restores original power plan

Global Variables

  • hw - Table with hardware information
    • hw.bits - CPU architecture (32 or 64 bit)
  • args - Command line arguments
  • beamng_platform - Current platform (“windows”, “linux”, etc)
Last modified: March 28, 2025

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.