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

MSFS Impossible to trigger some keyboard actions

Lagaffe

Resource contributor
Messages
864
Country
france
Hello,
In my last creation, I let the user assign the EXTEND SPOILERS and RETRACT SPOILERS commands to keyboard or joystick keys and I would like to retrieve these events in a gauge to be able to perform additional processing.
<Update id="EVENEMENTS">
<Script>
(>K:SPOILERS_ON) if{ -1 (>L:pBY_FloatsSwitch, enum) }
(>K:SPOILERS_OFF) if{ 1 (>L:pBY_FloatsSwitch, enum) }
(>K:SPOILERS_TOGGLE) if{ (L:pBY_FloatsSwitch, enum) -1 == if{ 1 (>L:pBY_FloatsSwitch, enum) } els{ -1 (>L:pBY_FloatsSwitch, enum) } }
</Script>
</Update>
I have tried the SPOILERS_ON, SPOILERS_OFF and SPOILERS_TOGGLE events but it doesn't seem to work.

Do theses actions correspond to other events than the ones mentioned above?
 
Last edited:
Messages
244
Country
unitedkingdom
Is this MSFS or FSX or P3D (you can set that in an option at the top of your question)? event handing is different in each of those although the XML looks similar. An immediate issue is your (>K:foo) code is TRIGGERING the event foo (because of the > in front of the K), so your update loop is triggering spoilers on/off/toggle in quick succession 18 times a second.

The general routine for "K" events is you use (>K:foo) XML to TRIGGER the event and in all the sims you can monitor a related underlying variable to DETECT the event (e.g. A:SPOILERS HANDLE POSITION). There's a fair amount of info on the internet (including this site) but it would be better to be specific about the sim before linking that, and each sim has addional options for running code when the event occurs.

IMHO for something like spoilers, I find monitoring the underlying variable a simple/consistent way of handling any changes - in my gliders it is common for the wheel brake to be applied when the spoilers are fully extended (e.g. the last 25% of the spoilers being opened applies 0..100% of the wheel brake). It sounds like your requirement will be simpler (e.g. are your spoilers binary open/closed?) but I suspect monitoring the A:SPOILERS HANDLE POSITION will still be a simple solution.

There are methods in each sim to trigger code based on 'binary' events, but with the specific example of spoilers the pilot can assign the spoilers to an axis so the spoilers can be opened 0..100% without triggering the SPOILERS ON event. In general I'd recommend getting familiar with detecting spoilers (or anything else) changing via the vars (it means remembering the previous value and only running code when it changes).
 

Lagaffe

Resource contributor
Messages
864
Country
france
Indeed, I had forgotten to specify but I just corrected: it was for MSFS.

In fact, I needed to rig my floats via a keyboard shortcut but in MSFS this does not exist. But spoilers can do this so I animated my floats as if they were spoilers with the possibility to manage an increase of drag when they are deployed and to manage the time they take to deploy with precision (spoiler_extension_time =10).

Except that I also wanted to manage visually the animation of the lever (three positions: retract - neutral - extend) that controls the floats/spoilers when you control them via one of the keyboard shortcuts.
That's why I was counting on the observation of these events to signal me the change of state of the floats/spoilers and command the correct movement of the lever./

In the end, yesterday I managed to finish 90% of my problem and it works very well. The only thing I have left is the lever animation when the shortcuts are used, the rest works perfectly.

Warning : my lever has a particular usage:
- neutral => the electrical motor is off
- retract => the motor is on and when the floats/spoilers are retracted, the lever should be placed at neutral to cut the motor
- extend ... idem

If I test A:SPOILERS HANDLE POSITION) when the value reach shoud be 0 or 16384 it is too late to commute the lever and just after put it on neutral position.
In fact it should be possible to detect the passage of this variable from 0 to x in one direction and from 16384 to x in the other direction. In the end trying to describe, I think I just found a solution.
 
Messages
87
Country
egypt
Hi,
K:events do not have value that can be used to set an L:Var..instead , use the corresponding A:var which will hold the value,
For example :
(A:SPOILERS HANDLE POSITION,percent) 1 &gt; if{ -1 (>L:pBY_FloatsSwitch, enum) } els{ 1 (>L:pBY_FloatsSwitch, enum) }
 
Messages
1,052
Country
australia
You can capture K: events from the user by using Bindings in InputEvents.

See this part of the SDK: https://docs.flightsimulator.com/ht...tBindings&rhsearch=bindings&rhhlterm=bindings

I use bindings to capture FUEL_PUMP, TOGGLE_ELECT_FUEL_PUMP and TOGGLE_ELECT_FUEL_PUMP1 events. Because I am using the new fuelsystem and the new fuelsystem has individual fuel pumps which you access with different commands (that are not mappable to the keyboard). By using Bindings I can capture the normal key commands for the fuel pump and use that to adjust the fuelsystem fuel switch.
 

Lagaffe

Resource contributor
Messages
864
Country
france
For the floats/spoilers challenge I had find yesterday a good solution based on (A:SPOILERS RIGHT POSITION, percent) and (>K:SPOILERS_SET, bool). Today, it works.

Lever part: with PBV_FloatsSwitch which can take -1(down), 0 (neutral) and 1(up) values
<PartInfo>
<Name>interupt_floats</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>50 (L:pBV_FloatsSwitch, enum) 1 + 25 * -</Code>
<Lag>50</Lag>
</Parameter>
</Animation>
<MouseRect>
<TooltipText>Extend (down) - Neutral - Retract (up)</TooltipText>
<Cursor>UpDownArrows</Cursor>
<MouseFlags>LeftSingle+WheelUp+WheelDown</MouseFlags>
<CallbackCode>
(L:pBV_FloatsSwitch, enum) 1 == (L:pBV_FloatsSwitch, enum) -1 == ||
if{
(M:Event) 'WheelUp' scmp 0 == if{ 0 (>L:pBV_FloatsSwitch, enum) }
(M:Event) 'WheelDown' scmp 0 == if{ 0 (>L:pBV_FloatsSwitch, enum) }
(M:Event) 'LeftSingle' scmp 0 == if{ 0 (>L:pBV_FloatsSwitch, enum) }
(M:Event) 'RightSingle' scmp 0 == if{ 0 (>L:pBV_FloatsSwitch, enum) }
}
(L:pBV_FloatsSwitch, enum) 0 ==
if{
(M:Event) 'WheelUp' scmp 0 == if{ 1 (>L:pBV_FloatsSwitch, enum) 0 (>K:SPOILERS_SET, bool) }
(M:Event) 'WheelDown' scmp 0 == if{ -1 (>L:pBV_FloatsSwitch, enum) 16384 (>K:SPOILERS_SET, bool) }
}
</CallbackCode>
</MouseRect>
</PartInfo>

Left Float animations (idem for right):
<Animation name="float_l" guid="25eabf14-0254-4a83-b442-09f1d23fba35" type="Sim" typeParam="AutoPlay" typeParam2="float_l" length="100"/>
<PartInfo>
<Name>float_l</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>
(A:SPOILERS LEFT POSITION, percent)
(A:SPOILERS LEFT POSITION, percent) 0 == (A:SPOILERS LEFT POSITION, percent) 100 == || if{ 0 (>L:pBV_FloatsSwitch, enum) }
</Code>
</Parameter>
</Animation>
</PartInfo>
This solution permit to use spoilers_extension_time to manage the retractation time of floats and permit to add drag when you extend the floats.

I have a second challenge with "water tanks" for firefiting Ops : trying to open the tanks with the TAILHOOK function and I will try this function to capture events.
The management of the weight of the water in the tanks is made withe HTML/JS script.

PS:
This SDK is horrible, I just saw that everything related to tailhook is only partially implemented if at all. So the solution to go through this is impossible.
The SMOKE_ENABLE commands are not configurable by keyboard shortcuts either!
The only solution what I see is to use the FLAPS.
 
Last edited:
Top