Editor Element Helper
Reusable form builder for editor UI - creates typed form elements (numeric, string, bool, transform, modelConfig, file, dropdown, vehicleFilter, zoneSelector, etc.) with automatic default data generat
Reusable form builder for editor UI - creates typed form elements (numeric, string, bool, transform, modelConfig, file, dropdown, vehicleFilter, zoneSelector, etc.) with automatic default data generation, container binding, issue checking, and drawing.
Class: C (returned by factory function)
Element Constructors
| Method | Description |
|---|---|
C:addCustomElement(label, getNewFn, setContainerFn, drawFn) | Adds a custom-drawn element |
C:addNumeric(label, fieldName, default, displayOptions) | Float input with optional min/max/unit |
C:addString(label, fieldName, default, len, displayOptions) | Text input with optional translation/dropdown |
C:addBool(label, fieldName, default, hideElementList, displayOptions) | Checkbox; can toggle visibility of other elements |
C:addTransform(label, fieldName, valueOptions, displayOptions) | Position/rotation/scale with gizmo and debug draw |
C:addModelConfig(label, fieldName, defaultModel, defaultConfig, displayOptions) | Vehicle model + config selector |
C:addFile(label, fieldName, default, allowedExtensions, displayOptions) | File path input with browse dialog |
C:addFixedFile(label, filepathsInFolder, displayOptions) | Fixed file existence check (no user edit) |
C:addRace(label, fieldName, default, ...) | Race path file selector (.path.json) |
C:addSimpleLapConfig(label, fieldName, displayOptions) | Lap configuration editor |
C:addSites(label, fieldName, default) | Sites file selector (.sites.json) |
C:addLeaderboard(label, fieldName, count, best, medium, worst) | Best/medium/worst result inputs |
C:addReward(label, fieldName, default) | Numeric reward value |
C:addDropdown(label, fieldName, values, default, tooltips) | Dropdown combo selector |
C:addVehicleFilter(label, fieldName, displayOptions) | Vehicle filter with probability settings |
C:addContainerId(label, fieldName, idType, default, displayOptions) | Mission/element ID reference |
C:addZoneSelector(label, fieldName, globalInfoFolderField, displayOptions) | Zone selection from sites file |
Decorators
| Method | Description |
|---|---|
C:addBigDecoHeader(text, color) | Large styled header text |
C:addDecoHeader(text, color) | Medium styled header text |
C:addDecoText(text, tooltip) | Descriptive text with optional tooltip |
C:addDecoSeparator() | Horizontal separator line |
C:addDecoSpacer() | Small vertical spacer (4px) |
C:addDecoDummy(height) | Custom-height vertical spacer |
Data & Container Operations
| Method | Description |
|---|---|
C:getNewData() | Returns table of {fieldName → defaultValue} for all elements |
C:setContainer(c) | Binds a container; calls setContainerFunctions for each element |
C:checkContainer(c, fix, tags) | Validates container data; returns issues array; auto-fixes if fix=true |
C:draw(filterOptions) | Draws all elements using ImGui; updates mouse info; handles transform editing |
C:clear() | Removes all elements |
C:getAllFieldNames() | Returns {fieldName, type, elemLabel} for all elements |
C:setAutoAdditionalAttributes(key, auto) | Marks key for auto-save to additional attributes |
Mouse & Transform Helpers
| Method | Description |
|---|---|
C:updateMouseInfo(container) | Updates raycast and closest-element hover state |
C:editingAnyTransform() | Returns true if any transform element is in edit mode |
C:drawTransformAsSphereDir(e) | Debug-draws a sphere with directional cone |
C:drawTransformAsVehicle(e) | Debug-draws a vehicle-shaped box |
C:drawAxisBox(corner, x, y, z, clr) | Debug-draws an axis-aligned box |
Usage Example
local elementHelper = require('/lua/ge/extensions/editor/util/editorElementHelper')
-- Create a helper for mission type data
local helper = elementHelper({}, 'mission')
-- Add form elements
helper:addDecoHeader("Spawn Settings")
helper:addTransform("Start Position", "start", {
defaultPos = vec3(0, 0, 0),
defaultRot = quat(0, 0, 0, 1),
hasPos = true, hasRot = true, hasScl = false
}, {drawMode = "vehicle", drawColor = {0, 1, 0, 0.5}})
helper:addModelConfig("Vehicle", "vehicle", "vivace", "Base")
helper:addNumeric("Time Limit", "timeLimit", 120, {min = 0, max = 600, unit = 'time'})
helper:addDropdown("Difficulty", "difficulty", {"Easy", "Normal", "Hard"}, "Normal")
helper:addBool("Allow Damage", "allowDamage", true)
helper:addDecoSeparator()
helper:addVehicleFilter("Traffic Filter", "vehicleFilters")
helper:addZoneSelector("Zones", "zones", "globalInfoFolder")
-- Bind to a mission container
helper:setContainer(missionContainer)
-- Draw the form in an editor window
helper:draw()
-- Get default data for new missions
local defaults = helper:getNewData()
-- Validate the container
local issues = helper:checkContainer(missionContainer, true) -- auto-fix
for _, issue in ipairs(issues) do
log("W", "", issue.label .. " [" .. issue.severity .. "]")
endModule Variables
setContainerBaseFunction- Alias forC.setContainer(base function reference)drawBaseFunction- Alias forC.draw(base function reference)
See Also
- Plot Helper Utility - Related reference
- Search Utility - Related reference
- Transform Utility - Related reference
- World Editor Guide - Guide
Editor Tool Utilities – Util
Common utility functions shared across spline-editing tools. Provides mouse interaction, raycasting, unit conversions, colour generation, spline helpers, GLTF export, and PNG debug output.
Plot Helper Utility
Interactive 2D graph/plot widget for ImGui - supports multi-series data, Catmull-Rom spline interpolation, auto-scaling, dragging, zooming, annotations, and tooltip hover.