• 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.

Make flap rocker switch back automatically

Horst18519

Moderator
Resource contributor
Messages
2,385
Country
germany
After quite a long time I have another question about panel modelling:

I have a flap rocker that increments/decrements flaps when pushed up/down. As it is a rocker it should automatically flip back to 0-position after switching.

I couldn't get this done in the modeldef.xml, it seems quite tricky.

I tried this code, but it doesn't seem to work:

<PartInfo>
<Name>fw_flaps_rocker</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>
(L:FW Flaps Rocker,number) 50 * 50 +
</Code>
<Lag>300</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<HelpID>HELPID_GAUGE_FLAPS_SWITCH</HelpID>
<TooltipID>TOOLTIPTEXT_FLAPS_ROCKER</TooltipID>
<MouseFlags>LeftSingle+LeftDrag+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmp 0 == if{ (L:FW Flaps Rocker, number) ++ (K:KEY_FLAPS_INCR) quit }
(M:Event) 'LeftRelease' scmp 0 == if{ (L:FW Flaps Rocker, number) -- (K:KEY_FLAPS_DECR) quit }
</CallbackCode>
</MouseRect>
</PartInfo>

Anyone an idea how to achieve this?
 
The code below should animate a lever keyframed at 0 - 50 - 100. Normal position is center OFF. Left-click will "increase flaps." Left-release will return lever to center OFF. Right-click will "decrease flaps." Right-release will return lever to center OFF.

Code:
   <PartInfo>
	<Name>Toggle_Flaps</Name>
	<AnimLength>100</AnimLength>
	<Animation>
		<Parameter>
			<Code>(L:FlapToggle,enum) 50 *</Code>
			<Lag>300</Lag>
		</Parameter>
	</Animation>
	<MouseRect>
		<Cursor>Hand</Cursor>
		<TooltipText>Flap Lever</TooltipText>
		<MouseFlags>LeftSingle+RightSingle+LeftRelease+RightRelease</MouseFlags>
			<CallbackCode>

				(M:Event) 'LeftSingle' scmp 0 ==
				if{ 0 (>L:FlapToggle, enum) (>K:FLAPS_INCR) }

				(M:Event) 'RightSingle' scmp 0 ==
				if{ 2 (>L:FlapToggle, enum) (>K:FLAPS_DECR) }

				(M:Event) 'LeftRelease' scmp 0 ==
				if{ 1 (>L:FlapToggle, enum) }

				(M:Event) 'RightRelease' scmp 0 ==
				if{ 1 (>L:FlapToggle, enum) }

			</CallbackCode>
	</MouseRect>
   </PartInfo>
 
Wow, thanks Bill.

It looks so easy, but it's still so tricky to me. Spent a lot of time with the SDK the last days, but there are still a lot of things I don't understand... :o
 
Ok, I even got the syntax for assigning values now. :)

One more question about this though:

If the aircraft moves and the curser slips off the rocker before the user releases the button the release action is obviously not played, meaning the rocker stays where it is (up or down). That doesn't influence the functionality, but it doesn't look nice.
Would there be a possibility to ensure the rocker goes back to neutral, say with a timer?
 
Ok, I even got the syntax for assigning values now. :)

One more question about this though:

If the aircraft moves and the curser slips off the rocker before the user releases the button the release action is obviously not played, meaning the rocker stays where it is (up or down). That doesn't influence the functionality, but it doesn't look nice.
Would there be a possibility to ensure the rocker goes back to neutral, say with a timer?

Yes, that is a problem, particularly with the "dynamic movement" in the VC which often means the part slides out from under the cursor! :scratchch

Yes, one could start a timer on first mouse-click, then have the timer reset the L:variable after some number of seconds. That "timer" would have to be part of a gauge file though, because there's no way to include such in a .mdl's embedded XML "code."
 
Thanks. I guess I will think about this as I create an XML gauge for my personal variables anyway.
 
Back
Top