RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorVehicle ExporterFollow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track GeneratorRectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot CreatorShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files SyntaxVehicle Rope DebugBatch WorkerWebSocket Test

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)

See Also

  • Auto Annotation - Related reference
  • Booster - Related reference
  • Calibrate ESC - Related reference
  • Game Engine Overview - Guide

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 ExportsSee Also