RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Rally Audio ManagerRally Camera Path PlayerRally ClientRally Cut CaptureRally EnumsRally Extension HelperRally GeometryRally ManagerRecce ManagerRecce AppRecce SettingsRally Settings ManagerSnap-to-RoadTraffic Exclusion ZonesRally UtilityRally Vehicle CaptureRally Vehicle Tracker
Rally CodriverRally Mission SettingsRally PacenotePacenote GeneratorPacenote WaypointNotebook PathStructured Pacenote DataSystem PacenotesWaypoint Types
Library CompositorStructured Pacenote SchemaText CompositorVisual Compositor

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 Extensionsgameplayrallynotebookstructured

Library Compositor

Core composition engine that converts structured pacenote fields into human-readable text phrases. Handles corner calls, caution phrases, modifiers, distance calls, finish lines, and phrase enumeratio

Core composition engine that converts structured pacenote fields into human-readable text phrases. Handles corner calls, caution phrases, modifiers, distance calls, finish lines, and phrase enumeration for TTS generation. Also provides weighted random selection for system pacenotes.


Public API

FunctionSignatureReturnsDescription
M.composite(config, structured, distBefore, distAfter, escapeVars?)tableComposes structured fields into array of phrase strings
M.enumerate(textCompositor, config)tableGenerates all possible phrase combinations for TTS pre-generation
M.getRandomWeightedItem(items)itemWeighted random selection from array of {weight} items
M.postProcessPhrase(phrase, punctuation)stringTrims and appends punctuation to phrase

Internals

Composition Pipeline (M.composite)

  1. Collect variables from structured fields + config lookups
  2. Build phrases in order:
    • Caution phrase (e.g., "caution" / "double caution")
    • Corner phrase (e.g., "4 right long tightens,")
    • Modifier phrases (e.g., "don't cut", "bumpy", "crest") - max 3
    • Finish line phrase
    • Distance after (e.g., "50,")
  3. Each phrase is post-processed (trimmed + punctuated)
  4. Returns array of strings (one per sub-phrase for TTS)

Variable Collection

VariableSourceDescription
cornerSeverityconfig.cornerSeverity nearest value lookupCorner rating name
cornerDirectionconfig.cornerDirection enum"left" / "right"
cornerLengthconfig.cornerLength nearest value"short" / "long" / etc.
cornerRadiusChangeconfig.cornerRadiusChange nearest value"opens" / "tightens"
cautionconfig.caution enumCaution level text
modifier1-3config.modifiers priority-sortedModifier text with priority
finishLineconfig.finishLine.textFinish line announcement
distanceBeforeraw or $db escapedDistance call before
distanceAfterraw or $da escapedDistance call after

Corner Phrase Assembly

[distanceBefore] cornerSeverity cornerDirection [cornerLength] [cornerRadiusChange]

Example: "50 4 right long tightens,"

getNearestValue

Used for cornerSeverity, cornerLength, cornerRadiusChange - finds closest matching entry from config values list:

for _, entry in ipairs(valuesList) do
  local diff = math.abs(entry.value - targetValue)
  -- track closest
end

Modifier Priority

Modifiers are sorted by priority field from config and limited to 3 max. First modifier can use textWhenFirst variant.

Enumeration (M.enumerate)

Generates all valid phrase combinations by iterating:

  • All caution levels × distance variants
  • All corner severity × direction × length × radius change × distance variants
  • All square corners × direction × length × radius change
  • All individual modifiers × distance variants
  • Finish line text

Used to pre-generate TTS audio files for the offline structured audio mode.

Weighted Random Selection

M.getRandomWeightedItem(items)
-- Normalizes weights, generates random 0-1, walks cumulative distribution
-- Default weight = 1 if not specified

How It Works

  1. Text compositor loads a language-specific config (corner names, modifier texts, punctuation)
  2. composite() maps structured field values → config lookups → phrase strings
  3. Distance calls ($db, $da) can be escaped for later interpolation or resolved immediately
  4. enumerate() produces all possible phrases for TTS pre-generation
  5. getRandomWeightedItem() selects system pacenotes (go, countdown, damage) with weight distribution

Usage Example

local LibCompositor = require('gameplay/rally/notebook/structured/libCompositor')

-- Compose a structured pacenote
local phrases = LibCompositor.composite(config, structured, "50", "into")
-- {"50 4 right long,", "don't cut,", "into,"}

-- Enumerate all phrases for TTS generation
local allPhrases = LibCompositor.enumerate(textCompositor, config)

-- Pick weighted random system pacenote
local item = LibCompositor.getRandomWeightedItem(noteSet)

See Also

  • Structured Pacenote Schema - Related reference
  • TextCompositor - Structured Pacenote Text Generation - Related reference
  • VisualCompositor - Pacenote Visual Icon Generation - Related reference
  • Gameplay Systems Guide - Guide

Waypoint Types

Defines waypoint type constants and shorthand labels for pacenote waypoints. Each pacenote has a corner-start and corner-end waypoint.

Structured Pacenote Schema

Defines the schema for structured pacenote fields - the machine-readable description format for rally corners, caution levels, modifiers, and special events. Provides field definitions with types, def

On this page

Public APIInternalsComposition Pipeline (M.composite)Variable CollectionCorner Phrase AssemblygetNearestValueModifier PriorityEnumeration (M.enumerate)Weighted Random SelectionHow It WorksUsage ExampleSee Also