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
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorExport (glTF)Follow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track (Gymkhana Generator)Rectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot Creator (Vehicle Thumbnails)ShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files Syntaxutil/vehicleRopeDebug - Rope Physics Debug UIutil/worker - Batch Job Workerutil/wsTest - WebSocket Test Server

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 Extensionsutil

Resave Materials

Batch-converts legacy TorqueScript material files (`materials.cs`) to the new JSON format.

Batch-converts legacy TorqueScript material files (materials.cs) to the new JSON format.


Overview

util_resaveMaterials scans the entire filesystem for materials.cs files, executes each via TorqueScript, collects the resulting SimObjects, and re-saves them in the new format using PersistenceManager. This is a one-time migration utility.

Extension path: lua/ge/extensions/util/resaveMaterials.lua


Exports (M)

FunctionSignatureDescription
onExtensionLoaded()Configures log filtering and starts the conversion job.
work(job)Coroutine job that performs the actual conversion.

Internals

Conversion Flow

  1. Creates a PersistenceManager instance.
  2. Finds all materials.cs files recursively from /.
  3. For each file with size > 0:
    • Executes via TorqueScriptLua.exec(fn).
    • Collects all SimObjects whose getFileName() matches the source file.
    • Marks each object dirty in the PersistenceManager.
    • Calls saveDirtyNewFormat() to write the new format.
    • Deletes the temporary SimObjects.
  4. Cleans up the PersistenceManager.

Helper: getSimObjects(fileName)

Iterates scenetree.getAllObjects(), returning those whose getFileName() matches the given path.

Job System

Uses core_jobsystem.create(work, 1) to yield every second, keeping the UI responsive.

Log Filtering

Sets IngameConsoleLogBlacklist and WinConsoleLogBlacklist to "DA" to suppress noisy debug output during conversion.


How It Works

  1. Load the extension (typically via CLI).
  2. onExtensionLoaded starts a background job.
  3. The job iterates all materials.cs files, executes them, and resaves in new format.
  4. Logs DONE on completion.

Lua Examples

-- Typically run as a batch tool:
-- beamng.exe -onLevelLoad_ext "util/resaveMaterials"

-- Or load manually:
extensions.load("util/resaveMaterials")

Additional Exports

  • M.onExtensionLoaded - (undocumented)
  • M.work - (undocumented)

Render Components API

Reads renderer component JSON files and provides an API to get/set rendering settings (shaders, post-effects, etc.).

Rich Presence

Manages Steam and Discord rich presence status, showing what the player is doing (level, vehicle, activity).

On this page

OverviewExports (M)InternalsConversion FlowHelper: getSimObjects(fileName)Job SystemLog FilteringHow It WorksLua ExamplesAdditional Exports