• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Dragging Lever

Messages
59
Country
france
It's me again. :rolleyes:

I would create a dragging lever to control a variable (L:Ma_Variable, enum) or (L:Ma_Variable, percent) -the easiest-

When the lever is pushed forward the value of the variable increases, and when it's pulled, the variable decreases.

Like the throttle, but without using variables FSX

The length of the animation would be 100.

Of course it is in modeldef.

Thank you in advance for your help
 
I wrote this code:

<PartInfo>
<Name>00-NORD_PressionAdmission</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>100 (L:Prop1 Pitch Lever, number) - </Code>​
</Parameter>​
</Animation>​
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Prop Pitch 1 %((L:Prop1 Pitch Lever, number))%!d</TooltipText>
<MouseFlags>LeftSingle+LeftDrag</MouseFlags>
<CallbackCode>(M:Event) 'LeftSingle' scmp 0 == if{ 100 (M:Y) - (&gt;L:MOUSEPOS, number) quit }
(M:Event) 'LeftDrag' scmp 0 == if{ (M:Y) (L:MOUSEPOS,number) - -0.5 * (L:Prop1 Pitch Lever, number) + 100 max 0 min (&gt;L:Prop1 Pitch Lever, number) (M:Y)(&gt;L:MOUSEPOS,number) }
</CallbackCode>​
</MouseRect>​
</PartInfo>

The Animlength is 100
The keyframes are placed at 0-50-100

The hand appears when I move the mouse on the lever

But :
  • the lever doesn't move.
  • the value of (L: Prop1 Pitch Lever, number) is always 0

What to do?

Thank for your help.
 
Hi,

I actually don't like Toms modification of the draggable-lever code. subtracting the Y from 100 doesn't seem logical to me, but anyway...

Your problem seems to be a misunderstanding of the min/max functions. You want your calculation to be SMALLER than 100 but LARGER then 0. You produced a code that is taking 100 if the variable is smaller than 100 and then sets it to 0 .

I won't give youi the solution, but I'm sure you'll figure it out from here :D

Cheers,
Vitus
 
I want to control manually the manifold pressure with this lever

I've modified my code in the following manner.

<PartInfo>
<Name>00-NORD_PressionAdmission1</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>100 (L:Pression_Admission_1, number) - </Code>
</Parameter>
</Animation>

<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Pression d'Admission: %((L:Pression_Admission_1, number))%!d</TooltipText>
<MouseFlags>LeftDrag</MouseFlags>

<CallbackCode>
(M:Event) 'LeftDrag' scmp 0 ==
if{ (M:Y) (L:MOUSEPOS,number) - -0.5 * (L:Pression_Admission_1, number) + -2 max 100 min (&gt;L:Pression_Admission_1, number) (M:Y) (&gt;L:MOUSEPOS,number) }
</CallbackCode>

</MouseRect>
</PartInfo>

I am only partially satisfied:

The lever moves in the direction I want.

  1. But when it is not at the minimum (-2), it jumps up to the maximum value (100), then follows the mouse.
  2. I don't know how to adapt this code to increase or decrease the manifold pressure.

Is this possible ? or should I look in another direction......but which one ?

Thank for your help.
 
Vitus that was changed in a later post in that thread, and I adopted that later code, as I stated.
 
Hello FBRTE,

there is no way of directly adjust the manifold pressure as far as I know. That is if you don't want to programm a C++ module and use simConnect...

However, you could implement some sort of PID controller that takes the manifold pressure as input and adjusts the throttle lever in order to achieve a set MAP. That can be achieved in XML, is a bit difficult though.

When I was first playing with the drag scripts I had the same problem of "jumping" levers when clicking on them for the first time. The reason was that all variables are initialized with "0" in your case it is most likely the L:MOUSEPOS variable that's causing the trouble.
To get rid of this issue I implemented a "LeftSingle" event as well that initializes the mousepos variable with the current mouse position.

Have a look at the drag-lever-thread in the "working XML" section over at fssdfdfsssfdfss to see what I mean - look at my second post for the latest version.
http://www.aerodynamika.com/cgi-bin/yabb2/YaBB.pl?num=1229500345

What I don't get from your example is the -2. It means that you animate the lever with keyframes 0 to 102 is that correct?
If so - why?

Vitus that was changed in a later post in that thread, and I adopted that later code, as I stated.

Hello Tom,

I know, I followed the discussion. I still don't see the point ;)
The way I approach all these animations is the following:
1. I analyze the movement of the lever and decide on the KF range I use. Sometimes its easier to animate a lever from 0-80 instead of 0-100 to keep the maths simple (especially for snap-levers).
2. I decide if KF0 means "down", "up", "left", "right",...
3. I do the programming of the animation, and at that point I don't include ANY functionality. I just make sure that the lever moves in a proper way.
4. The last step is to add functionality on top of it.

Basically the animation is separate from the function of the lever, and that makes the code reusable, easily customizable, easier to maintain.

Cheers,
Vitus
 
Hello Vitus,

Thank you for your advice

I have adopted your code and it works perfectly ... to move the lever.

The minimum at -2 was an attempt to see if I could have negative values.

The engine control of the Noratlas is a bit complicated.

Indeed, the pilot adjusts the RPM with the propeller lever, then, to obtain the desired power, adjusts the desired manifold pressure with the throttle .

From 100 to 0 the throttle determines the manifold pressure, and the propeller lever the RPM.
But from 0 to -45 the throttle controls the reverse, and the propeller lever the feathering!

So I've created two sets of each lever. One visible when the value is equal or greater than 0, the other when the value is less than 0 .... and, for the throttle, when the reverse lock is open.

I'm not sure to sleep tonight!
 
I'm wondering..... Generally speaking what you describe is pretty much what every throttle lever of a piston engine does don't you think? The only difference might be that the MAP stays more or less constant with one setting.
An easy way around this could be to setup a turbocharger for your aircraft.

You can define the turbochargers maximum altitude in the aircraft.cfg. If you set this value to, say, 10,000 feet the MAP will stay more or less constant throughout your climb until you reach this altitude.

I'm happy that you got it running now. It sounds a bit complicated using visi-tags and different levers for different kinds of operation, but if it works for you that's just fine.

Have a nice day,
Vitus
 
Back
Top