# Between contition for animated windsock

#### mamu

Hi!.
First of all I would like to thank you again for your usefull help. This site and this forum is like founding a goldmine!
I'm near the last step into creating my first "well made" scenery: adding a good animated windsock is still a problem without vertex animation, but I got decent results.
Now it's time to get it rotating according to wind direction.
So I've made a set of windsocks mdls pointing 0-60-120-180-240-300° (for both low-mid and high speed wind)
I ran MDLTweaker II (what a wonderful tool!) and put wind velocity conditions: ok, they behave quite correctly.
Next step is to add wind heading condition. The little help says I must use 0 to 65535 value for 0 to 360 degrees. But, if I write a number > 32767 in the box the program give me "Overflow" runtime error. (only 16 bit values admitted?)
I tried with negative values (0 to 32767, -32767 to -1) but I'm not sure this is the right way. For example, using the following table, for the 120° mdl I wrote min 16384 and max 27306, and for the 360 (0) mdl I wrote min -5461 and max 5461
Code:
``````Values are obtained using the formula (Degree * 65535)/360
Value' is the "should be" range from 0 to 65535
Value'' are range from -32767 to 32767

Degrees	Value'	Value''
0	-	-
30	5461	5461
60	-	-
90	16384	16384
120	-	-
150	27306	27306
180	-	-
210	38229	-27306
240	-	-
270	49151	-16384
300	-	-
330	60074	-5461
360	-	-``````

Now my windsock is animated, rotates accordingly to the wind, has different model for no wind, low-mid wind and high wind BUT it requires a full restart of FS to see changes... Where is the trick?

#### arno

Staff member
FSDevConf team
Resource contributor
Hi,

Yes, the way you handle the negative values looks correct. That error is a good one, I did not think about that before. The code does not know if you are using signed or unsigned values and that makes a difference when trying to write back into the object. I'll try to prevent that error in the future.

The problem you mention with the objects not responding is also a common one. Objects that interact with the wind only work if you have placed at least two of them on your screen. And those two objects must not be at exactly the same location. So you might want to add another windsock somewhere else (maybe hidden in a building or so).

#### mamu

I have already two windsocks at both runway ends .

I've noticed, however, that the "bug" disappears if I look away from the object after changing weather. It is not so cool..but, it works, so, I'm quite happy

#### arno

Staff member
FSDevConf team
Resource contributor
If at least two of the objects are on your screen (not in the scenery) at the same time, it should work right away. But this is indeed a bit of a tricky bug to work with.

#### danchircop

Hi all,
i'm having a similar problem here, in displaying an object according to wind direction. I did manage to get the object to be displayed when the wind is between 0 to 179 degrees, however beyond that, the object doesn't get displayed anymore.
For example if I want an object to be displayed between 090-150 is used the values (min)16384 - (max)27306 and that worked fine.
Beyond 180 degrees I tried using the negative value idea as mentioned here, since I also got the overflow error. So, if I wanted the object to be displayed when the wind is between 090-270 I used (min)16384 - (max)-16384.
However in this case the object never got displayed. What could be the problem?

Thanks
Daniel

#### mamu

it's quite simple: with values like (min)16384 - (max)-16384 you are going counterclockwise, wich is not good.
In order to have your object displayed correctly, your condition should be:

(min)16384 - (max) 32767
OR
(min)-32767 - (max) - 16384

This
mamu said:
(0 to 32767, -32767 to -1)

means: values are from -32767 to 32767 (180° to 180° clockwise)

#### danchircop

Thanks for the explanation Mamu, i did get part of what I want working, but I'm still having difficulty with another situation.

First of all I did manage to get the object to appear beyond the 180degree threshold. I wanted an object to appear between a wind direction of 250-070 with values (min-20024) - (max12743) and it works correct now.

However how about if i want another object to appear between the 070-250 zone? I can't start the value with a minus (ie -12743) coz that would mean a wind direction of 290. If I start with a postive going to a negative it would be anti-clockwise.
So in my case do i have to split it up in to 2 parts? IE from 070 - 180 (using a positive value) and 180 - 250 (using a negative value). At the moment it seems the only way out.

Thanks
Daniel

#### mamu

So in my case do i have to split it up in to 2 parts? IE from 070 - 180 (using a positive value) and 180 - 250 (using a negative value). At the moment it seems the only way out.

Thanks
Daniel
That is the way I got it working . With MDLTweaker you can't add condition linked with AND and the OR logical operator at the same time. So, if you have to check wind speed AND wind direction, you must use 2 different object (well, the same object tweaked into different ways). Otherwise, if you don't care about wind speed, then you can link you conditions with OR logical operator (please see the following steps):

1- open the object 070-250 width MDLTweaker II
3- select the variable Wind direction from the variable dropdown list
4- use (min)16384, (max) 32767
5- click new condition
6- select the logical operator OR in the new dropdown list that is appeared
7- select the variable Wind direction from the variable dropdown list
8- use (min)-32767, (max) - 16384
9- click apply to object and save
10- it must be working

Hope this helps!

#### danchircop

Thanks Mamu it all works nicely now.