RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Editor AI TestsEditor AI VisualizationEditor – Assembly Spline ToolAsset BrowserAsset DeduplicatorAsset Management ToolSFX Previewer (Audio Events List)Audio Ribbon EditorAutoSaveBarriers EditorBiome ToolBuilding EditorBulk RenameCamera BookmarksCamera TransformCamera Path EditorCEF HelperCo-Simulation Signal EditorCrawl Data EditorCreate Object ToolDataBlock EditorDecal EditorDecal Spline EditorDocumentation HelperDrag Race EditorDrift Data EditorDrive Path EditorDynamic Decals Tool (Vehicle Livery Creator)Engine Audio DebugExtensions DebugExtensions EditorFFI Pointer Leak TestFile DialogFlowgraph EditorForest EditorForest ViewEditor Gizmo HelperEditor Ground Model Debug HelperEditor Headless Editor TestEditor Icon OverviewEditor ImGui C DemoEditor InspectorEditor Layout ManagerEditor Level SettingsEditor Level ValidatorEditor LoggerEditor Log HelperEditor MainEditor Main MenuEditor Main ToolbarEditor Main UpdateMap Sensor EditorMaster Spline EditorMaterial EditorMeasures Inspector HeaderMesh Editor (Base)Mesh Road EditorMesh Spline EditorMission EditorMission PlaybookMission Start Position EditorMulti Spawn Manager (Vehicle Groups)Navigation Mesh EditorEditor News MessageObject Tool (Object Select Edit Mode)Object To Spline EditorParticle EditorPerformance Profiler / Camera RecorderPhysics ReloaderPrefab Instance EditorEditor PreferencesRace / Path EditorRally EditorRaycast Test Editor ToolRenderer Components Editor ToolRender Test Editor ToolResource Checker Editor ToolRiver EditorRoad Architect EditorRoad DecorationsRoad Editor (Decal Road)Road Network ExporterRoad River Cache HandlerRoad River GUIRoad Spline EditorRoad Template EditorRoad UtilitiesScene TreeScene ViewScreenshot Creator BootstrapScript AI EditorScript AI ManagerSensor Configuration EditorSensor DebuggerShape EditorShortcut LegendSidewalk Spline EditorSites EditorSlot Traffic EditorSuspension Audio DebugTech Server ManagerTerraform ToolTerrain And Road ImporterTerrain EditorTerrain Materials EditorText EditorTool ManagerTool ShortcutsTraffic DebugTraffic ManagerTraffic Signals EditorUndo History ViewerVehicle Bridge TestVehicle Detail ViewerVehicle Editor MainEditor - VisualizationEditor Viz HelperEditor Water Object HelperEditor Windows Manager
Gen Decal EditorGen Experimental Frame EditorGen Mesh ExplorerGen Experimental SolidFlexGen Mesh ModuleGen Network ModuleGen Region ModuleGen Render ModuleGen Terrain ModuleEditor Gen TestEditor Gen Top (Roof Geometry)Editor Gen UI (Building Architect UI)Editor Gen UtilsEditor Gen World

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 Extensionseditorgen

Editor Gen World

Central world/scene management module for the Building Architect Tool (BAT). Manages the full lifecycle of procedural buildings: creation, editing, material assignment, forest item placement, DAE expo

Central world/scene management module for the Building Architect Tool (BAT). Manages the full lifecycle of procedural buildings: creation, editing, material assignment, forest item placement, DAE export, terrain conforming, undo/redo, and session save/load.


Module Overview

AspectDetail
Fileextensions/editor/gen/world.lua
ReturnsW table (global world state)
Requireseditor/gen/mesh, editor/gen/utils, editor/gen/decal, editor/gen/render, editor/gen/top, editor/gen/network, editor/gen/terrain, editor/gen/test
Size~17,800 lines - largest BAT module

Key State

FieldTypeDescription
W.uitableAll UI-bound parameters (floor height, window spacing, material lists, seed, etc.)
W.outtableRuntime output state (selections, debug draws, mode flags)
adesctablemesh_id → building_descriptor - all active buildings
cedittableCurrent edit state: {mesh, part, forest, aforest, cval}
dforesttableforest_key → {item, mesh, type, ind, prn} - forest item registry
ddaetabledae_path → {type, fr, to, fo, list, w, h} - loaded DAE metadata

Public Functions - Building Lifecycle

FunctionDescription
W.houseUp(desc, id)Creates or updates a procedural building mesh from descriptor
W.houseDown(desc, fkeep)Converts procedural mesh to static TSStatic (fkeep = keep forest items)
W.houseSave(desc, name)Saves building to JSON + exports DAE + forest items to level
W.daeExport()COLLADA export dialog for current building with forest items
W.toLevel(desc, pth)Writes building DAE and forest placement JSON to level directory

Public Functions - Editing

FunctionDescription
W.scopeOn(scope)Sets edit scope: 'building', 'floor', 'wall', 'side', 'top'
W.forScope()Returns current scope and cij (floor/wall indices)
W.markUp()Updates visual selection markers
W.matApply(name, index)Applies material to current scope selection
W.meshApply(type, index)Applies mesh variant (window, door, etc.)
W.selectionHide()Toggles visibility of selected elements

Public Functions - Forest Items

FunctionDescription
W.ifForest(types)Checks if current selection has forest items of given types
W.forDAE(type)Returns DAE path list for given element type
W.pref2dae(pref)Resolves a DAE prefix group to its first DAE path
W.splineUp(desc, ifloor, key, sdata)Generates spline-based wall with window/door holes and forest items

Public Functions - Session & Undo

FunctionDescription
W.onQuit(forestoff)Cleanup on editor exit - removes edit group, forest items
W.recover(jdesc, cb, keep)Restores buildings from JSON descriptor table
W.ifSaved()Checks if session save file exists
W.reload(mode)Hot-reloads all sub-modules, optionally switches mode

Public Functions - Terrain

FunctionDescription
W.conform(desc)Conforms terrain to building footprint
W.confSave()Commits terrain modifications
W.restore(tosave)Reverts terrain height changes
W.matUp()Loads wall and roof material libraries from JSON files

Building Descriptor Structure

desc = {
  id = meshId,           -- ProceduralMesh object ID
  pos = vec3,            -- World position
  afloor = {             -- Array of floors
    {
      h = 3.2,           -- Floor height
      pos = vec3,        -- Floor offset
      base = {vec3...},  -- Footprint polygon
      awall = {          -- Array of walls
        {
          u = vec3,      -- Wall direction vector
          v = vec3,      -- Wall up vector
          mat = "name",  -- Material name
          win = "path",  -- Window DAE path
          door = "path", -- Door DAE path
          df = {},       -- Forest item registry {dae_path → {key_list}}
        }
      },
      top = {            -- Roof descriptor
        shape = "ridge", -- flat/pyramid/shed/gable/ridge
        margin = 0.4,
        tip = 2,
        mat = "material",
        achild = {},     -- Child roof sections
      }
    }
  },
  data = {mdata...},     -- Compiled mesh data for rendering
}

DAE Asset Loading

-- Assets loaded from standard path
local assetPath = '/art/shapes/common/building_architect_modules'

-- Element types loaded: windows, doors, corner, balcony, pillar,
-- store_front, stairs, basement_plinth, gutter, fire_stairs,
-- string_course, wall_pilaster, roof_border

Module Variables

  • adae (table) - Module variable.
  • mpoint (any) - Module variable.
  • dmat (any) - Module variable.
  • pretest (any) - Module variable.

Functions

daeReg(pth, tp)

Handles dae reg.

  • pth (any)
  • tp (any)

Returns: string.sub(s, 2)

forSpline()

Handles for spline.

Returns: boolean - true

forJSON(obj)

Handles for json.

  • obj (object)

Returns: end

floorClear(f)

Handles floor clear.

  • f (any)

Returns: end

atParent(desc)

Handles at parent.

  • desc (any)

Returns: end

selectionTurn(ang, center)

Handles selection turn.

  • ang (any)
  • center (any)

Returns: desctop,base

building4test(num, R, center, istemplate)

Handles building4test.

  • num (number)
  • R (any)
  • center (any)
  • istemplate (any)

Returns: end

buildingScan(desc, ondone)

Handles building scan.

  • desc (any)
  • ondone (any)

buildingLOD(desc, arc)

Handles building lod.

  • desc (any)
  • arc (any)

forRoof(desctop, cb)

Handles for roof.

  • desctop (any)
  • cb (any)

Returns: end

matScale(scale)

Handles mat scale.

  • scale (vec3|number)

Returns: end

topClear(desctop)

Handles top clear.

  • desctop (any)

Returns: im.IsKeyDown(editor.keyModifiers.shift)

floorSplit(f, j, p, shapekeep)

Handles floor split.

  • f (any)
  • j (any)
  • p (any)
  • shapekeep (any)

Returns: end

ray2rc(ray, floor)

Handles ray2rc.

  • ray (any)
  • floor (any)

Returns: nil

floorChildrenOff(floor)

Handles floor children off.

  • floor (any)

Returns: newfloor

floorDel(desc, ind)

Handles floor del.

  • desc (any)
  • ind (any)

Returns: end

voice2build(cmd)

Handles voice2build.

  • cmd (any)

Returns: end

overWall()

Handles over wall.

Returns: end

inView()

Handles in view.

Returns: end

cornerUp(desc, dae, toreplace)

Handles corner up.

  • desc (any)
  • dae (any)
  • toreplace (any)

Returns: a[1] < b[1]

hasExtra(tp, dobj)

Checks if has extra.

  • tp (any)
  • dobj (any)

Returns: end

wallMatch(cw, f)

Handles wall match.

  • cw (any)
  • f (any)

Returns: end

ifPairHit(ij)

Handles if pair hit.

  • ij (any)

Returns: nil,apair[i]

ifPairEnd(ij, dbg)

Handles if pair end.

  • ij (any)
  • dbg (any)

Returns: nil,apair

childRebase(achild, val, sbase, j, cbase, toemu)

Handles child rebase.

  • achild (any)
  • val (any)
  • sbase (any)
  • j (any)
  • cbase (any)
  • toemu (any)

Returns: end

mat2xml(fname)

Handles mat2xml.

  • fname (any)

persist(ahouse)

Handles persist.

  • ahouse (any)

forHit(ray, desc)

Handles for hit.

  • ray (any)
  • desc (any)

toggle(tp, dae)

Handles toggle.

  • tp (any)
  • dae (any)

clear(mode)

Handles clear.

  • mode (any)

forestEdit(key)

Handles forest edit.

  • key (string)

forestClean(desctop, dbg)

Handles forest clean.

  • desctop (any)
  • dbg (any)

Returns: jsonEncode(adesc)

goAround(dir)

Handles go around.

  • dir (string)

matMove(ds, isrel)

Handles mat move.

  • ds (any)
  • isrel (any)

partOn(id)

Handles part on.

  • id (number)

Returns: cij

isHidden()

Checks if hidden.

Returns: yes

wallSplit()

Handles wall split.

onKey(key)

Callback for key event.

  • key (string)

keyUD(dir)

Handles key ud.

  • dir (string)

keyRL(dir)

Handles key rl.

  • dir (string)

keyAlt(yes)

Handles key alt.

  • yes (any)

keyShift(yes)

Handles key shift.

  • yes (any)

mdown(rayCast, inject)

Handles mdown.

  • rayCast (any)
  • inject (any)

Returns: forHit(ray, adesc[cedit.mesh])

mdrag(rayCast)

Handles mdrag.

  • rayCast (any)

mup(rayCast, inject)

Handles mup.

  • rayCast (any)
  • inject (any)

mwheel(dir, rayCast)

Handles mwheel.

  • dir (string)
  • rayCast (any)

Returns: boolean - true

windowsToggle()

Handles windows toggle.

Returns: v - start

doorToggle()

Handles door toggle.

pillarToggle()

Handles pillar toggle.

atticToggle()

Handles attic toggle.

corniceToggle()

Handles cornice toggle.

Returns: a[1] < b[1]

baseSet(nm)

Handles base set.

  • nm (any)

roofSet(nm)

Handles roof set.

  • nm (any)

forDesc()

Handles for desc.

Returns: adesc[cedit.mesh]

ifValid(tp)

Handles if valid.

  • tp (any)

Returns: boolean - true

ifRoof(nm)

Handles if roof.

  • nm (any)

Returns: boolean - false

ifTopRect()

Handles if top rect.

Returns: #base == 4 and isRect(base)

buildingGen(p, base, intest)

Handles building gen.

  • p (any)
  • base (any)
  • intest (any)

forHeight(flist, i)

Handles for height.

  • flist (any)
  • i (number)

Returns: h

forSel()

Handles for sel.

Returns: adsc

forTop()

Handles for top.

Returns: desctop,base

forSide(ij, fromselect)

Handles for side.

  • ij (any)
  • fromselect (any)

Returns: aij

base2world(desc, ij, p)

Handles base2world.

  • desc (any)
  • ij (any)
  • p (any)

Returns: table|any

onVal(key, val)

Callback for val event.

  • key (string)
  • val (any)

onUpdate()

Callback for update event.


Missing Exports (Added by Audit)

up(d, inreload, inact, mode)

Main initialization/setup entry point.

  • d (any) - Init data
  • inreload (boolean) - Whether called during reload
  • inact (any) - Active state
  • mode (string) - Operating mode

undo()

Undoes the last building edit operation.

conform(desc)

Conforms terrain to building footprint.

  • desc (table) - Building descriptor

confSave()

Commits terrain height modifications to the terrain block.

restore(tosave)

Reverts terrain height changes.

  • tosave (boolean) - Whether to save before restoring

M.wallCut()

Empty stub on the extension module table (M). No-op.

Exported Fields

FieldTypeDescription
W.uitableAll UI-bound parameters
W.outtableRuntime output state
W.adesctablemesh_id → building_descriptor registry
W.dmattableMaterial dictionaries (wall, roof, ext, road)
W.testanyTest module reference
W.pretestanyPre-test state
W.mpointanyMouse point state

See Also

  • Gen Decal Editor - Related reference
  • Gen Experimental Frame Editor - Related reference
  • Gen Mesh Explorer - Related reference
  • World Editor Guide - Guide

Editor Gen Utils

Core utility library for the Building Architect Tool. Provides geometric math (line intersection, polygon operations, splines), array/string helpers, debug drawing, camera control, file I/O, and the s

Gen AI Library

Gradient descent optimization library for the gen editor's experimental tools.

On this page

Module OverviewKey StatePublic Functions - Building LifecyclePublic Functions - EditingPublic Functions - Forest ItemsPublic Functions - Session & UndoPublic Functions - TerrainBuilding Descriptor StructureDAE Asset LoadingModule VariablesFunctionsdaeReg(pth, tp)forSpline()forJSON(obj)floorClear(f)atParent(desc)selectionTurn(ang, center)building4test(num, R, center, istemplate)buildingScan(desc, ondone)buildingLOD(desc, arc)forRoof(desctop, cb)matScale(scale)topClear(desctop)floorSplit(f, j, p, shapekeep)ray2rc(ray, floor)floorChildrenOff(floor)floorDel(desc, ind)voice2build(cmd)overWall()inView()cornerUp(desc, dae, toreplace)hasExtra(tp, dobj)wallMatch(cw, f)ifPairHit(ij)ifPairEnd(ij, dbg)childRebase(achild, val, sbase, j, cbase, toemu)mat2xml(fname)persist(ahouse)forHit(ray, desc)toggle(tp, dae)clear(mode)forestEdit(key)forestClean(desctop, dbg)goAround(dir)matMove(ds, isrel)partOn(id)isHidden()wallSplit()onKey(key)keyUD(dir)keyRL(dir)keyAlt(yes)keyShift(yes)mdown(rayCast, inject)mdrag(rayCast)mup(rayCast, inject)mwheel(dir, rayCast)windowsToggle()doorToggle()pillarToggle()atticToggle()corniceToggle()baseSet(nm)roofSet(nm)forDesc()ifValid(tp)ifRoof(nm)ifTopRect()buildingGen(p, base, intest)forHeight(flist, i)forSel()forTop()forSide(ij, fromselect)base2world(desc, ij, p)onVal(key, val)onUpdate()Missing Exports (Added by Audit)up(d, inreload, inact, mode)undo()conform(desc)confSave()restore(tosave)M.wallCut()Exported FieldsSee Also