GE Lua Documentation

Press F to search!

validateVehicleDataColor

Definition


-- @/lua/ge/ge_utils.lua:961

function validateVehicleDataColor(color)
  local validatedColor = color or "1 1 1 1"
  if type(color) == 'string' then
    local components = string.split(validatedColor)
    validatedColor = string.format("%0.2f %0.2f %0.2f %0.2f", tonumber(components[1]), tonumber(components[2]), tonumber(components[3]), tonumber(components[4]))
  elseif type(color) == 'table' then
    validatedColor = string.format("%0.2f %0.2f %0.2f %0.2f", color[1] or 1, color[2] or 1, color[3] or 1, color[4] or 1)
  end
  return validatedColor
end

Callers

@/lua/ge/extensions/scenario/scenarios.lua
    if scenario.userSelectedVehicle.color then
      scenario.userSelectedVehicle.color = validateVehicleDataColor(scenario.userSelectedVehicle.color)
    end
@/lua/ge/ge_utils.lua
  if color then
    local colorStr = validateVehicleDataColor(color)
    color = stringToTable(colorStr)