Sites Editor
Main editor extension for creating/editing gameplay sites (locations, zones, parking spots). Provides an ImGui-based editor window with tabs, file I/O, sorting tools, and sites manager integration.
Main editor extension for creating/editing gameplay sites (locations, zones, parking spots). Provides an ImGui-based editor window with tabs, file I/O, sorting tools, and sites manager integration.
Public Functions
| Function | Description |
|---|---|
M.onEditorGui() | Draws the main Sites Editor ImGui window with menu bar and tabs |
M.onEditorInitialized() | Registers the editor window, edit mode, and sub-editors |
M.onEditorToolWindowHide(windowName) | Switches to objectSelect mode when window is hidden |
M.onEditorToolWindowGotFocus(windowName) | Switches to sites edit mode when window gets focus |
M.onSerialize() | Serializes current sites state |
M.onDeserialized(data) | Restores sites from serialized data |
M.allowGizmo() | Returns true if sites edit mode is active |
M.getCurrentSites() | Returns the current sites object |
M.getCurrentLocation() | Returns the currently selected location |
M.getCurrentZone() | Returns the currently selected zone |
M.getCurrentParkingSpot() | Returns the currently selected parking spot |
M.selectZone(elem, mode) | Selects a zone element |
M.show() | Shows the editor window and activates edit mode |
M.loadSites(loadPath) | Loads sites from a .sites.json file |
M.saveSites(sites, savePath) | Saves sites to a .sites.json file |
M.managerSites() | Draws the Sites Manager submenu (browse by level) |
Example: Sites Editor Workflow
-- The Sites Editor is an extension-based editor tool
-- It registers itself during onEditorInitialized and creates sub-editors:
-- Tab structure:
-- 1. Locations - point-based gameplay locations with radius
-- 2. Zones - polygon-based areas with vertices
-- 3. Parking Spots - oriented bounding boxes for vehicle placement
-- 4. Loc Tags - tag management for locations
-- 5. Parking Spot Tags - tag management for parking spots
-- 6. Zone Tags - tag management for zones
-- File operations via menu:
-- File > New - creates empty sites
-- File > Load - opens .sites.json file dialog
-- File > Save / Save As - writes current sites to disk
-- Tools menu provides sorting utilities:
-- Sort Locations/Zones/Parking Spots by Name
-- Enumerate Parking Spots - auto-number duplicate names
-- Parking Spot Names by Zone Containment - rename spots to zone name
-- Accessing current state from other extensions:
local sitesEditor = extensions.editor_sitesEditor
local sites = sitesEditor.getCurrentSites()
local location = sitesEditor.getCurrentLocation()
local zone = sitesEditor.getCurrentZone()
local spot = sitesEditor.getCurrentParkingSpot()
-- Loading sites programmatically:
local sites = sitesEditor.loadSites("/gameplay/sites/my_site.sites.json")
-- Saving sites:
sitesEditor.saveSites(sites, "/gameplay/sites/my_site.sites.json")
-- Show the editor:
sitesEditor.show()Architecture
The editor uses a tabbed window pattern with pluggable sub-editors:
locations.lua- location element editor (position + radius gizmo)zones.lua- zone polygon editor (vertex manipulation)parkingSpots.lua- parking spot editor (pos/rot/scale + multi-spot)sortedListDisplay.lua- generic sorted list UI wrappertags.lua- tag management UI for any element type
Each sub-editor implements: init, setSites, select, draw, selected, unselect
Module Variables
onExtensionLoaded(any) - Module variable.
Additional Exports
M.onExtensionLoaded
See Also
- Editor AI Tests - Related reference
- Editor AI Visualization - Related reference
- Editor – Assembly Spline Tool - Related reference
- World Editor Guide - Guide
Sidewalk Spline Editor
Editor tool for placing sidewalk meshes along splines - uses mesh kits with base pieces and variations, supports distribution control (round-robin/random with weights), terrain conforming/terraforming
Slot Traffic Editor
Editor extension for editing navgraph-based traffic slot configurations - provides a visual node/link editor for road networks with traffic lane assignment, road properties, and navgraph manipulation.