Vehicle Selector – Tile Clustering
Groups vehicle configurations into clustered tiles by brand/model or model key.
Groups vehicle configurations into clustered tiles by brand/model or model key.
Overview
ui_vehicleSelector_tileClustering handles clustering individual vehicle configs into visual tiles for the vehicle selector grid. Supports two modes: brandSubModelOrModel (groups by brand + submodel) and model (groups by model key). Also computes favourite/recent stats and source icons for each cluster.
Extension path: lua/ge/extensions/ui/vehicleSelector/tileClustering.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
clusterItems | (configs, clusterMode) → table | Groups configs into clusters keyed by cluster label. |
createTileFromClusteredItems | (clusteredItems, group, clusterMode) → tile | Creates a UI tile from a cluster. |
getClusterModeFunction | (clusterMode) → fn | Returns the clustering key function. |
getClusteredItemsFavouriteIconPercent | (clusteredItems) → ... | Returns favourite/recent stats for a cluster. |
getClusteredItemsStats | (clusteredItems, sortMode) → preview, model, config, last | Returns preview image and representative config. |
getSources | (config, model, onlyIcons) → string[] | Returns source labels/icons for a config. |
Internals
Cluster Modes
| Mode | Key Function |
|---|---|
brandSubModelOrModel | Brand + " " + SubModel (falls back to model key) |
model | config.model_key |
clusterItems
Returns { [clusterLabel] = { configsByKey, count, list, years, value } }.
Tile Creation
Both createTileFromBrandSubModelOrModel and createTileFromModel produce tiles with:
key,name,preview,subElementCountfavouriteIdx,recentIdx,showFavouriteIconPercentgotoPath- navigation path for drilling into configsdoubleClickDetails- model/config for double-click action- Performance stats:
Value,Weight,Top Speed,Power,0-60 mph, etc. sourceIcons- array of{icon}or{svg}objectsisAuxiliary- true only if all configs in cluster are auxiliary
Source Icons
getSources returns icons based on:
BeamNG - Official→"beamNG"Custom→"wrench"- Automation type → SVG path
- Has
modID→"puzzleModule" - Missing JBeam →
"danger"
How It Works
clusterItemsgroups configs by the chosen mode function.- For each cluster,
createTileFromClusteredItemsbuilds a tile with preview, stats, and source icons. - The tile's
gotoPathallows the UI to navigate into the cluster's configs. - Favourite/recent stats determine star icons and sorting priority.
Lua Examples
local tileClustering = require('/lua/ge/extensions/ui/vehicleSelector/tileClustering')
-- Cluster configs by brand+submodel
local clusters = tileClustering.clusterItems(configList, "brandSubModelOrModel")
-- Create a tile from a cluster
for label, cluster in pairs(clusters) do
local tile = tileClustering.createTileFromClusteredItems(cluster, group, "brandSubModelOrModel")
endAdditional Exports
The following exports are available but not yet documented in detail:
M.clusterItemsM.createTileFromClusteredItemsM.getClusterModeFunctionM.getClusteredItemsFavouriteIconPercentM.getClusteredItemsStatsM.getSources