fix ulc light

This commit is contained in:
2024-11-09 19:11:52 -08:00
parent fb48efb2a9
commit 86e3baab44
43 changed files with 6299 additions and 704 deletions
+13 -32
View File
@@ -1,6 +1,8 @@
-- Returns: bool (whether vehicle was found), table (vehicle config info)
function GetVehicleFromConfig(vehicle)
for _, v in pairs(Config.Vehicles) do
for _,v in pairs(Config.Vehicles) do
-- if old method with just a string
if v.name then
-- find which vehicle matches
@@ -8,6 +10,7 @@ function GetVehicleFromConfig(vehicle)
--print("Vehicle [" .. v.name .. "] was found in Config.")
return true, v
end
elseif v.names then -- if new method with a table
-- for each name check if it matches the vehicle
for _, n in ipairs(v.names) do
@@ -70,41 +73,19 @@ function IsVehicleHealthy(vehicle)
end
end
function SortButtonsByKey(arr)
function SortButtonsByKey (arr)
table.sort(arr, function(a, b)
return a["key"] < b["key"]
end)
end
function formatInt(num)
local formatted = tostring(num)
local length = formatted:len()
for i = length - 3, 1, -3 do
formatted = formatted:sub(1, i) .. ',' .. formatted:sub(i + 1)
end
return formatted
end
function validateButtonText(text)
local count = 0
for word in text:gmatch("%w+") do
count = count + 1
if count > 3 or #word > 5 then
return false
end
end
return true
end
-- Function to check if a value exists in a table
-- Returns: bool (whether value is contained), int (index of value if contained)
function contains(table, val)
for i, v in ipairs(table) do
if v == val then
return i
end
end
return false
local formatted = tostring(num)
local length = formatted:len()
for i = length - 3, 1, -3 do
formatted = formatted:sub(1, i) .. ',' .. formatted:sub(i + 1)
end
return formatted
end