Hello, i have run into some sort of a problem, i have to make one value decrease, as other value increases. like so:
Property a is a Float set at 25.000
Property b is a Float set at 0.000
As property b increases way up to 60.000, Property a will decrease to a minimum of 4.000, even though Property b still increases.
Can someone halp me with that?
Many thanks in advance.
MarcoIT
(MarcoIT)
2
if B > 60.0 :
A -= something
if A < 4.0 :
A = 4.0
can be?
or :
if B > 60.0 :
dif = B - 60.0
B = 60.0
A -= dif
if A < 4.0 :
A = 4.0
I guess that would make B decrease constantly, even though A is not increasing.
It has to be proportional, like if A is 30, B should be 10.5
Or, B will decrease exactly by 1, as A increases exactly by 2.4
Sjoerd
(Sjoerd)
4
There you go:
# bb = b clamped to 0-60.0
bb = max(0.0, min(b, 60.0))
a = 25.0 - 21.0 * bb/60.0
Wow, that worked great, i don’t know exactly how it works but, it worked, many thanks!
Could you tell me what exactly this code does?
Sjoerd
(Sjoerd)
6
It does what you described in the first post
bb is just b, except that it can’t be larger than 60 or smaller than 0
i see, very clever, congratulations!