1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

# Scaling of values for SetValue calls

Discussion in 'Programming Questions and Suggestions' started by mze9412, Mar 9, 2015.

This last post in this thread was made more than 31 days old.
1. ### mze9412Junior Engineer

Messages:
791
Hi everyone,

could someone maybe explain the logic behand the scaling of the values you need to use for the SetValue commands? Thrusters for example do not start at 0 but on 120 (small) and 1200 (large) in small grids. Also their maximum values are kind of strange. I would have expected a scaling from 0 to 100 or 0.00 to 1.00 in percent. No override is 120 for small thrusters, I would have expected something like 0 or even double.NaN.

I know how it works but I am still confused as to why it works this way o_O

2. ### PhoeraSenior Engineer

Messages:
1,713
because you set not percent of trust, but actual trust value.
So, all logical.

3. ### JoeTheDestroyerJunior Engineer

Messages:
573
Yes, you set the thrust in Newtons, not percent. Use GetMaximum() if you want percent:
Code:
```IMyThrust th;
float percent=50;
th.SetValueFloat("Override",percent/100.0f*th.GetMaximum&lt;float>("Override"));```
I like it this way as I can actually calculate the effect of a thrust setting. I wish the gyroscopes worked the same way...

As for disabling the override, setting to 0 works for me (in code, the GUI won't accept it, though).

You've only scratched the surface of thruster weirdness, though. Someday I may get around to posting what I've discovered so far... If you want one example, although the minimum settable thrust is 1% of max +1N, the the thruster won't actually do anything until roughly 2% of max.

Last edited by a moderator: Mar 9, 2015
4. ### mze9412Junior Engineer

Messages:
791
I know that is is in Newton, but why is 120 the minimum and not 0? You can set 0 but in the UI as you said it is 120 At least I would have expected some special value to denote "no thrust". Having 0-120 all behave as "no thrust" is just plain stupid in my opinion :\ I guess also negative values would work as "no thrust".

I also had the problems with thrusters and very low override settings. It did not move until I set it to higher values and sometimes I even had strange boundaries where it did not move with one settings, adding 1N to the thrust suddenly made it jump forward.
And for rotors some things are strange if you want to limit minimum and maximum rotation angles. I think -361 or something like that was used. Is that still logical? Not for me, sorry