1

I want to write a function in lua that given a number from 0 to 1, it decreases proportionally another number from 0.1 to 0.001.

I tried to apply the proportional inverse y=1/x but is not working as I think it does or i'm doing it wrong. What principles should I apply here?

This is what I have:

    local input = read_float(heatPath+offset)
    local heat = input
    local time = read_float(timePath+offset)
    If heat ~= 0 then
       local heat_increment = heat * 10
       local new_time = heat_increment/time

Edit: So, a guy told me that is more complex than that. Something involving a derivative and an integral. Honestly I don't have idea how to do that. I'll appreciate any help or guidance regarding that.

  • 1
    Please add an example with numbers (input. output) to better understand what do you want to achieve. – ESkri Apr 14 '23 at 09:37
  • Now I know that what I want to do is a PID controller for given a heat number from 0.00000 to 1.00000, the charging time function value of a weapon object decreases proportionally from 0.1 to 0.001. So, once the weapon object start firing, heat value rise up, and then charging time value goes shorter, resulting in the weapon object firing faster as it heatens. – StealthYakumama May 02 '23 at 02:55

0 Answers0