API ReferenceGE Extensionseditor
Road Utilities
Utility module for road template operations - handles template loading, child road creation, decoration placement, random decal generation, and material management.
Utility module for road template operations - handles template loading, child road creation, decoration placement, random decal generation, and material management.
Public API
| Function | Signature | Description |
|---|---|---|
M.updateChildRoads | (road) | Recreates child DecalRoads from a road's template, computing widths and positions |
M.reloadTemplates | () | Scans level's roadtemplates/ folder, loads materials, and applies templates to all roads |
M.getMaterials | () | Returns loaded material texture objects array |
M.getMaterialNames | () | Returns material name strings array |
M.getRoadTemplateFiles | () | Returns array of .road.json file paths |
M.reloadDecorations | (road) | Recreates 3D decorations for a road from its template |
M.reloadDecals | (road, template?) | Recreates random decals for a road from its template |
Key Internal Functions
| Function | Purpose |
|---|---|
getRoadWidth(road, metres) | Interpolates road width at a given metre position along the spline |
randomizeDecoration(decoID, factor) | Applies random position/rotation jitter to decoration objects |
Template Application Flow
reloadTemplates()scans for.road.jsonfiles in level'sroadtemplates/folder- For each template road: applies fields to primary road, creates child roads with relative positioning
- Decorations are placed using
roadDecorations.decorateProps()with spacing, rotation, alignment - Random decals are generated with probability, size ranges, and horizontal offset
Usage Example
-- Reload all road templates (call after editing templates):
editor_roadUtils.reloadTemplates()
-- Get available template materials for UI:
local mats = editor_roadUtils.getMaterials()
for i, mat in ipairs(mats) do
-- mat.texId for thumbnail rendering
endNotes
- Requires
roadTemplates.general.loadTemplatespreference to betrue - Road resolution: 2 meters between sample points
- Child roads use
canSave = false- not persisted to disk - Calls
be:reloadCollision()after template application
Module Variables
onEditorInitialized(nil) - Module variable.
Module Variables
onEditorInitialized(nil) - Module variable.
Additional Exports
M.onEditorInitialized
See Also
- Editor AI Tests - Related reference
- Editor AI Visualization - Related reference
- Editor – Assembly Spline Tool - Related reference
- World Editor Guide - Guide
Road Template Editor
Editor window for creating, editing, saving, and loading road templates - composite road definitions with multiple DecalRoad layers, 3D decorations, and random decal patterns.
Scene Tree
The editor's scene tree window - a hierarchical tree view of all scene objects with filtering, drag-and-drop reordering, multi-selection, prefab support, virtual scrolling, and undo/redo for group ope