This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Calculate value to procent
#2
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.

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))
Reply


Messages In This Thread
Calculate value to procent - by Tokatubs - 10.06.2021, 18:55
RE: Calculate value to procent - by benanderson_475 - 11.06.2021, 02:51
RE: Calculate value to procent - by Tokatubs - 11.06.2021, 08:05
RE: Calculate value to procent - by admin - 11.06.2021, 08:11
RE: Calculate value to procent - by Tokatubs - 11.06.2021, 08:27
RE: Calculate value to procent - by tomnord - 07.05.2022, 14:29
RE: Calculate value to procent - by admin - 02.05.2022, 13:08

Forum Jump: