GE Lua Documentation

Press F to search!

money

Definition


-- @/lua/ge/extensions/ui/vehicleSelector/vehicleSpecifications.lua:119
  money = function(value)
    -- Format with comma separators for thousands and dot for decimals
    if not type(value) == 'number' then
      return tostring(value)
    end
    local formatted = string.format("%.2f", value)
    local integerPart, decimalPart = formatted:match("([^%.]+)%.?(.*)")

    -- Add comma separators to integer part
    local len = #integerPart
    local parts = {}
    for i = len, 1, -3 do
      local start = math.max(1, i - 2)
      table.insert(parts, 1, integerPart:sub(start, i))
    end

    local result = table.concat(parts, ",")
    if decimalPart and decimalPart ~= "" then
      result = result .. "." .. decimalPart
    end

    return "$"..result
  end,

Callers