11.06.2021, 02:51
(This post was last modified: 11.06.2021, 02:51 by benanderson_475.)
Looks like the above function you posted is javascript... are you running this in the custom javascript scripting part of lm?
if not and assuming you want lua try the below.
if not and assuming you want lua try the below.
Code:
function rangePercentage (input, range_min, range_max, range_2ndMax)
percentage = ((input - range_min) * 100) / (range_max - range_min)
if percentage > 100 then
if range_2ndMax then
percentage = ((range_2ndMax - input) * 100) / (range_2ndMax - range_max)
if percentage < 0 then
percentage = 0
else
percentage = 100
end
end
else if percentage < 0 then
percentage = 0
end
end
return percentage
end
log(rangePercentage (65, 46, 195, 195))