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

FSXA Animating a 12 position knob

Messages
683
Country
us-california
I have this knob that triggers a test of various warnings that must be brought to life. The animation can use a local variable, but the mouse clicks must also pass a custom event for a CW turn or CCW turn.

test.jpg

Any thoughts on how to code this would be greatly appreciated!
 
Code:
<PartInfo>
<Name>Test Knob</Name>
<AnimLength>360</AnimLength>
<Animation>
<Parameter>
<Code>(L:KnobPosition,number) 30 *</Code>
<Lag>70</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<MouseFlags>LeftSingle+RightSingle</MouseFlags>
<TooltipText>Test knob</TooltipText>
<CallbackCode>
(M:Event) 'LeftSingle' scmi 0 == if{ (L:KnobPosition, number) ++ 12 % (>L:KnobPosition, number) (>K:YourCustomEvent1) }
(M:Event) 'RightSingle' scmi 0 == if{ (L:KnobPosition, number) d 0 == if{ 11 } els{ -- } (>L:KnobPosition, number) (>K:YourCustomEvent2) }
</CallbackCode>
</MouseRect>
</PartInfo>

Don't pin me on the animation part; I wrote that one from memory. And I haven't worked with custom events yet, so no idea about the "K:".
 
By pass a custom event do you mean pass to a C++ gauge for processing? If so then do you really need to send CW or CCW information to the C++ gauge as well? I'd simply pass the new position of the L:var and when that is received compare that with the last value the C++ gauge received to determine which way the knob has been turned.
 
Here is how I approach the task. The C++ gauge monitors a single (L:EVENT,enum) variable. The hex event ID is sent to that L:var for decoding. Note that for consistency I use one of the hex event ID's as the animation control variable, such as below. The script can be easily expanded for any number of positions. This particular control has 50 positions. Simply change to 12 for your knob:
Code:
  <PartInfo>
    <Name>B350i_FGS_VS_SEL</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:0x110D0,enum)
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle+RightSingle+Wheel+DownRepeat+MiddleSingle+MiddleRelease</MouseFlags>
      <CallbackCode>
        (M:Event) 'RightSingle' scmp 0 ==
        (M:Event) 'WheelUp' scmp 0 == or
        if{ (L:0x110D0, enum) -- (>L:0x110D0, enum) 0x110D0 (>L:EVENT,enum) 1 (>L:XMLSND2,bool) (L:0x110D0, enum) 0 &lt; if{ 50 (>L:0x110D0, enum) } }
 
        (M:Event) 'LeftSingle' scmp 0 ==
        (M:Event) 'WheelDown' scmp 0 == or
        if{ (L:0x110D0, enum) ++  (>L:0x110D0, enum) 0x110D1 (>L:EVENT,enum) 1 (>L:XMLSND2,bool) (L:0x110D0, enum) 50 &gt; if{ 0 (>L:0x110D0, enum) } }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Last edited:
Back
Top