fixed a rare NaN lua error

This commit is contained in:
Meow
2026-03-11 05:14:35 +01:00
parent c503635622
commit 313f01f191
+1
View File
@@ -1391,6 +1391,7 @@ end
-- return r,g,b and hexcolor -- return r,g,b and hexcolor
local gradientcolors = {} local gradientcolors = {}
function pfUI.api.GetColorGradient(perc) function pfUI.api.GetColorGradient(perc)
if not perc or perc ~= perc then perc = 0 end -- NaN guard: NaN ~= NaN is true in Lua
perc = perc > 1 and 1 or perc perc = perc > 1 and 1 or perc
perc = perc < 0 and 0 or perc perc = perc < 0 and 0 or perc
perc = floor(perc*100)/100 perc = floor(perc*100)/100