getRandomPaints
Definition
-- @/lua/ge/extensions/core/vehiclePaints.lua:568
-- gets random paint data, given a model key and a config key
local function getRandomPaints(model_key, config_key)
local modelData = core_vehicles.getModel(model_key)
local model = modelData.model
if not model.randomPaintHelper then
setupRandomPaintHelper(model_key)
end
local paintHelper
local config = modelData.configs[config_key]
if config then
paintHelper = config.randomPaintHelper
end
paintHelper = paintHelper or model.randomPaintHelper
local randomNum = math.random() * paintHelper.totalProbability
local sum = 0
for _, paintResult in ipairs(paintHelper.allPaintResults) do
sum = sum + paintResult.probability
if randomNum < sum then
return paintResult
end
end
end
Callers
@/lua/ge/extensions/core/vehiclePaints.lua
end
local paints = getRandomPaints(model, config)
if not paints then
for i = 1, amount do
local paintResult = getRandomPaints(model_key, config_key)
local name = string.format("%s: %s %s %s", paintResult.type, paintResult.paintName1, paintResult.paintName2, paintResult.paintName3)
@/lua/ge/extensions/core/multiSpawn.lua
if options.randomPaints or options.paintName == '(Random)' or options.paintName2 == '(Random)' or options.paintName3 == '(Random)' then -- some backwards compatibility
local randomPaints = core_vehiclePaints.getRandomPaints(options.model, options.config)
if randomPaints and randomPaints.paintName1 then