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

P3D v2 Test Switch, Return to Off Problem

Messages
10,163
Country
us-arizona
Hey all,

I cant seem to get a switch to return to OFF position. You click it, its on, release and its off.

I have tried Mouse; Release, LeftRelease, and neither work. I have several versions of animation code for the switch (L:LJ24B GEAR ANUN TEST, bool) and nothing I do seems to work.

This one just seems to click with no animation. (Could be too fast, so its not moving??)



Code;

Code:
  <PartInfo>
    <Name>learjet24_gear_test</Name>
    <AnimLength>100</AnimLength>
    <Animation>
            <Parameter>
                <Code>(L:LJ24B GEAR ANUN TEST, bool) 100 *</Code>
                <Lag>950</Lag>
            </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Gear Retract System Test</TooltipText>
      <MouseFlags>LeftSingle+LeftRelease</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmi 0 == if{
                                           (L:LJ24B GEAR ANUN TEST, bool) ! (>L:LJ24B GEAR ANUN TEST, bool)
                                         1 (&gt;L:XMLSND1,enum)
                                         1 (&gt;L:XMLSND157,enum)
                                           }
        (M:Event) 'LeftRelease' scmi 0 == if{
                                           (L:LJ24B GEAR ANUN TEST, bool) ! (>L:LJ24B GEAR ANUN TEST, bool)
                                         1 (&gt;L:XMLSND1,enum)
                                            }
      </CallbackCode>
    </MouseRect>
  </PartInfo>


Variations;
Code:
        (M:Event) 'LeftSingle' scmi 0 == if{

                                           (L:LJ24B GEAR ANUN TEST, bool) ! (>L:LJ24B GEAR ANUN TEST, bool)


        (M:Event) 'LeftRelease' scmi 0 == if{

                                           (L:LJ24B GEAR ANUN TEST, bool) ! (>L:LJ24B GEAR ANUN TEST, bool)





        (M:Event) 'LeftSingle' scmi 0 == if{

                                           1 (>L:LJ24B GEAR ANUN TEST, bool) }

        (M:Event) 'LeftRelease' scmi 0 == if{

                                           0 (>L:LJ24B GEAR ANUN TEST, bool) }




        (M:Event) 'LeftSingle' scmi 0 == if{

                                           (>L:LJ24B GEAR ANUN TEST, bool) }

        (M:Event) 'LeftRelease' scmi 0 == if{

                                           (>L:LJ24B GEAR ANUN TEST, bool) }




        (M:Event) 'LeftSingle' scmi 0 == if{

                                           (>L:LJ24B GEAR ANUN TEST, bool) }

        (M:Event) 'LeftRelease' scmi 0 == if{

                                           0 (>L:LJ24B GEAR ANUN TEST, bool) }



Any idea's what I am doing wrong?
 
Problem now with animations. For some reason, the code is not triggering the animations. This is now occurring on two of these kinds of switches.

Code:
      <CallbackCode>
        (M:Event) 'LeftSingle' scmi 0 == if{
                                         1 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
                                         1 (&gt;L:XMLSND157,enum)
                                           }
        (M:Event) 'LeftRelease' scmi 0 == if{
                                         0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
                                         1 (&gt;L:XMLSND157,enum)
                                           }
        (M:Event) 'LeftDrag' scmi 0 == if{
                                         0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
                                         1 (&gt;L:XMLSND157,enum)
                                           }

      </CallbackCode>


Does anything look odd? The click sound works fine. The animation does not, and the flag L:var does not illuminate the Annunciator gauge, like its not transmitting the code, bottle necked.
 
Code:
<PartInfo>
<Name>learjet24_gear_test</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>(L:LF24B ANNUNCIATOR TEST SWITCH,bool) 100 *</Code>
<Lag>950</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Gear Retract System Test</TooltipText>
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmi 0 == if{
1 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
1 (&gt;L:XMLSND157,enum)
}
(M:Event) 'LeftRelease' scmi 0 == if{
0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
1 (&gt;L:XMLSND157,enum)
}
(M:Event) 'LeftDrag' scmi 0 == if{
0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
1 (&gt;L:XMLSND157,enum)
}
</CallbackCode>
</MouseRect>
</PartInfo>

Does that work?

Also make sure that the animation has one of these headers with a unique GUID.
 
Code:
......
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmi 0 == if{
1 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
1 (&gt;L:XMLSND157,enum)
}
(M:Event) 'LeftRelease' scmi 0 == if{
0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
1 (&gt;L:XMLSND157,enum)
}
(M:Event) 'LeftDrag' scmi 0 == if{
0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool)
1 (&gt;L:XMLSND157,enum)
}
</CallbackCode>
</MouseRect>
</PartInfo>

Just a couple of simple hints regarding <Click>/<CallbackCode> behavior:

The XML script will execute only if any of the mouse flags coincides with the current action.
In the example above, LeftDrag was not defined as a flag to monitor, therefore (M:Event) 'LeftDrag' scmi 0 == won't execute ever.

If a single action is peformed in all of the mouse flags events, it can be placed only once within the script:
Code:
<CallbackCode>
     (M:Event) 'LeftSingle' scmi 0 ==
     if{ 1 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool) }
     (M:Event) 'LeftRelease' scmi 0 ==
     if{ 0 (>L:LF24B ANNUNCIATOR TEST SWITCH,bool) }
     1 (>L:XMLSND157,enum)  (* Single action, write it here *)
</CallbackCode>

Now regarding the use of Drag events (left-right) to resolve the "out-of area lock" effect, the problem here is sensivity. If a switch/button has to go back when dragged to pretend it was released, as soon as the cursor is moved slightly the event will trigger, giving the sensation that the switch/button was never pressed/clicked. The best solution I've found is to add a timer that triggers inside the Drag code, and resets the variable to a released state n seconds after the cursor was dragged outside its mouse area.

Tom
 
I would also add to the discussion by suggesting that a "<Lag>950</Lag>" is rather strange, not to mention pointless. If you want fast animation, just leave out the <Lag> entry entirely. It's main purpose is to slow things down, which of course means really lower numbers... :teacher:
A lag can be entered so a part will not jump instantaneously from one state to the next.
Lag is measured in the maximum number of keyframes per second. So, for example, if the animation frame length is 50, and the lag is set to 400, the animation will take a minimum of 50/400 or one eighth of a second to complete.
 
I would also add to the discussion by suggesting that a "<Lag>950</Lag>" is rather strange, not to mention pointless. If you want fast animation, just leave out the <Lag> entry entirely. It's main purpose is to slow things down, which of course means really lower numbers... :teacher:

Thanks Bill, good point. I'll experiment with this.
 
If a single action is peformed in all of the mouse flags events, it can be placed only once within the script:
Tom

Tom,
If I have a mouserect/button and I want it to have 3 actions, does this mean that a mouserect will only do one function? For instance, can I have something make a sound, turn something on, and also activate a switch L:var or animation? Or can they only have 'one' action at all, total?
 
No, it means if an "action" -a portion of XML script - repeats on every mouse event in a <Click/CallbackCode>, it doesn't need to be placed -repeated - within the specific logic of each event.

For example, if you have this:

Code:
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmi 0 ==
if{
      (* specific code goes here *)
     1 (>L:XMLSND157,enum)
}
(M:Event) 'LeftRelease' scmi 0 ==
if{
       (* another specific code goes here *)
      1 (>L:XMLSND157,enum)  
}
</CallbackCode>

Assignment to (L:XMLSND157,enum) var is the same for 'LeftSingle' and 'LeftRelease' events.
Hence, it can be written only once:

Code:
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmi 0 ==
if{
      (* specific code goes here *)
}
(M:Event) 'LeftRelease' scmi 0 ==
if{
       (* another specific code goes here *)
}
1 (>L:XMLSND157,enum)  (* Here is OK *)
</CallbackCode>

This example is very basic, but I hope you get the idea :cool:

Tom
 
AHHHH.......! Roger. Stacking more codes/commands outside of the M: / if zones. Nice....! Many thanks Tom. Helps me tremendously.
 
Of course, if you don't want the "click" to be heard on button release, simply leave things alone and remove the "click" from the release event! :scratchch
 
Back
Top