API ReferenceGE Extensionsutil
Config List Generator
Vehicle config list filtering and random selection system. Used for generating lists of vehicles that match specific criteria (e.g., for dealerships, traffic, career mode).
Vehicle config list filtering and random selection system. Used for generating lists of vehicles that match specific criteria (e.g., for dealerships, traffic, career mode).
Overview
util_configListGenerator provides filtering and weighted random selection of vehicle configurations. Supports whitelist/blacklist filters on vehicle attributes (type, year, brand, etc.) with probability-weighted selection across filter groups.
Extension path: lua/ge/extensions/util/configListGenerator.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
getEligibleVehicles | (allowAuxiliary, allowLoadedTrailers) | Returns filtered list of eligible vehicle configs. |
getRandomVehicleInfos | (filterSet, numberOfVehicles, eligibleVehicles, popAttribute) | Returns N randomly selected vehicles matching filters. |
doesVehiclePassFilter | (vehicleInfo, filter) | Tests if a vehicle passes a whitelist/blacklist filter. |
Internals
Eligible Vehicle Filtering
getEligibleVehicles() excludes:
- Props (
Type.Prop,Type.PropParked,Type.PropTraffic) - Utility vehicles (
Type.Utility) - Vehicles without a
Value - Auxiliary vehicles (unless
allowAuxiliaryVehiclesis true) - Loaded trailers (unless
allowLoadedTrailersis true)
Filter Structure
Filters use whitelist/blacklist with attribute matching:
local filter = {
whiteList = {
Type = {"Car", "Truck"},
Years = {min = 1990, max = 2020},
Brand = {"Gavril"}
},
blackList = {
Type = {"Electric"}
},
probability = 5 -- Weight for random selection
}Attribute Matching
- Dict attributes (Brand, Type, etc.): Checked against
vehicleInfo.aggregates[attr]lookup dict. - Years: Range-checked against
aggregates.Years.min/max. - Numeric attributes: Range-checked with
min/max. - Other attributes: Exact value match.
Random Selection
- Filters are chosen by probability weight.
- A random model is selected from filtered configs.
- A random config for that model is selected by
popAttribute(default:"Population"). - Selection without replacement-chosen configs are removed from the pool.
How It Works
- Call
getEligibleVehicles()to get the base vehicle pool. - Call
getRandomVehicleInfos(filterSet, count)with a filter set containingfilterand optionalsubFilters. - SubFilters are merged with the base filter to create aggregated filter variants.
- The system picks filters by probability, then picks vehicles matching that filter.
Lua Examples
-- Get all eligible vehicles
local vehicles = extensions.util_configListGenerator.getEligibleVehicles()
-- Get 10 random vehicles matching a filter set
local filterSet = {
filter = {
whiteList = { Type = {"Car"} }
},
subFilters = {
{ whiteList = { Brand = {"Gavril"} }, probability = 3 },
{ whiteList = { Brand = {"ETK"} }, probability = 2 },
}
}
local picks = extensions.util_configListGenerator.getRandomVehicleInfos(filterSet, 10)
-- Check if a single vehicle passes a filter
local passes = extensions.util_configListGenerator.doesVehiclePassFilter(vehicleInfo, {
whiteList = { Type = {"Truck"} }
})Additional Exports
M.doesVehiclePassFilter- (undocumented)M.getEligibleVehicles- (undocumented)M.getRandomVehicleInfos- (undocumented)