RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
ui/ambientSound - Ambient Sound Stream PlayerUI Apps ManagerUI AudioBindings LegendCamera Distance AppConsole (consoleNG)Credits MusicExternal App (WebSocket UI Server)Fade ScreenGame BlurGameplay App ContainersGrid SelectorLivery EditorMessages DebuggerMessages/Tasks App ContainersMission InfoPolice InfoTop BarUI ModsUI Navigation / MapVehicle Paint EditorVehicle Vicinity AppUI Visibility

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsui

ui/ambientSound - Ambient Sound Stream Player

Reference for `extensions.ui.ambientSound`, which plays randomized ambient sound streams from JSON configuration files.

Reference for extensions.ui.ambientSound, which plays randomized ambient sound streams from JSON configuration files.


Overview

Manages multiple ambient sound streams, each containing a pool of sound files. Randomly selects sounds from each stream, plays them with configurable delays, and cycles through the pool without repeating the same sound consecutively. Used for environmental ambiance (wind, birds, traffic, etc.).


Exports

KeySignatureDescription
init(json) -> streamIDLoad a sound stream from a JSON config file
update(dt)Called each frame to advance sound playback
deleteSoundSFX(ID)Remove a sound stream by its ID
setStreamState(streamID, volume, pitch, fadeInTime)Modify stream playback parameters

Internals

  • soundStreams: Array of stream objects, each containing:
    • sounds - Array of sound file paths
    • delay - {min, max} or {max} for random delay between sounds
    • volume, pitch, fadeInTime - Playback parameters
    • currentSoundData - Currently playing sound state
    • previousSound - Index of last played sound (to avoid repeats)
    • streamID - Unique integer identifier
  • Playback: Uses Engine.Audio.playOnce('AudioGui', path, options) which returns {len = duration}
  • Cycling: After currentTime > delay + length, selects next random sound

How It Works

-- Initialize an ambient sound stream from JSON
local streamId = extensions.ui_ambientSound.init('/ui/ambientSounds/forest.json')

-- Modify stream parameters
extensions.ui_ambientSound.setStreamState(streamId, 0.5, 1.0, 2.0)

-- Remove stream
extensions.ui_ambientSound.deleteSoundSFX(streamId)

JSON Config Format

{
  "data": {
    "sounds": [
      "art/sound/ambient/birds_01.ogg",
      "art/sound/ambient/birds_02.ogg",
      "art/sound/ambient/birds_03.ogg"
    ],
    "delay": [3, 10]
  }
}

Update Loop

-- Called each frame (typically from onUpdate hook)
extensions.ui_ambientSound.update(dt)

-- Internally:
-- 1. Check if current sound is playing
-- 2. If not, start playback via Engine.Audio.playOnce
-- 3. Track elapsed time
-- 4. When elapsed > delay + sound_length, pick next random sound

Notes

  • Default volume is 0.29 (hardcoded in playOnce call)
  • Sounds never repeat consecutively (random selection with previous exclusion)
  • Delay can be a range [min, max] or single value [max] (min defaults to 1)
  • Stream IDs are sequential integers starting from 1
  • Files are validated with FS:fileExists() before playback

Additional Exports

The following exports are available but not yet documented in detail:

  • M.deleteSoundSFX
  • M.init
  • M.setStreamState
  • M.update

trackbuilder/trackBuilder - Track Builder Editor UI

Reference for `extensions.trackbuilder.trackBuilder`, the ImGui-based editor UI for building procedural race tracks.

UI Apps Manager

Core manager for UI app discovery, layout loading/saving, and layout versioning.

On this page

OverviewExportsInternalsHow It WorksJSON Config FormatUpdate LoopNotesAdditional Exports