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

FS2004 Proper Code for Press/Release

Messages
10,163
Country
us-arizona
Hey all,

How is the proper way to write a click/on and release? (Example; test button; push (blinkie lights come on), release (blinkie lights go back to sleep).

I looked through the FS2004 Panel SDK and couldn't find this. It has to do with LeftRelease mouse event.


This is the only example I have which is complicated enough to throw me off on how it works.

Code:
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>(M:Event) 'LeftSingle' scmp 0 == if{ (L:LHC_WHEELSKIRTS_DISPLAY,enum) 1 + 2 % (>L:LHC_WHEELSKIRTS_DISPLAY,enum) 1 (>L:XMLSND4,enum) 1 (>L:lhc_Push_WheelSKirts,bool) } (M:Event) 'LeftRelease' scmp 0 == if{ (>L:lhc_Push_WheelSKirts,bool) }</CallbackCode>


I do not fully understand what 'scmp' means, but from what I see above, it stays at zero for both LeftSingle and LeftRelease, so that must mean animation returns to zero KF point?


So would the following be proper?

Code:
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmp 0 == (>K:Meh)
(M:Event) 'LeftRelease' scmp 0 == 0 (>K:Meh)
</CallbackCode>

How would your Var event be written (typically) for the LeftRelease?
 
Here is an example from the default MakeMDLParts xml file:

Code:
<callback_code>
	(M:Event) 'LeftRelease' scmp 0 == if{ 0 (&gt;L:GOVERNOR RPM SWITCH, enum) quit }
	(M:Event) 'LeftSingle' scmp 0 == if{ (M:Y) (&gt;G:Var1) 0 (&gt;L:GOVERNOR RPM SWITCH, enum) quit }
	(M:Y) (G:Var1) - 5 / int s0 0 &gt; if{ (&gt;K:DECREASE_HELO_GOV_BEEP) -1 (&gt;L:GOVERNOR RPM SWITCH, enum) }
	l0 0 &lt; if{ (&gt;K:INCREASE_HELO_GOV_BEEP) 1 (&gt;L:GOVERNOR RPM SWITCH, enum) }
	l0 0 == if{ 0 (&gt;L:GOVERNOR RPM SWITCH, enum) }
</callback_code>

So yes, your code looks OK to me.

I believe that scmp stands for "String Compare", and if it equals 0 you have an exact match to the mouse event.

Hope this helps,
 
Hey Tom,

Many thanks. I didn't think to see if there were other LeftRelease variants in the parts sheet.

What I need to know is how do you write a code of mevents so that something turns on and off. How do you get a L:var for instance to only be on when holding the mouse key down.

EDIT: This is what I am trying to get to work. This is a small test button on a RAD Altimeter; click sound and tone sound and a flag appears 'during' the left-click time. Release and it should all turn off. Needs to only do this when electrics/battery are on. I have modified this quite a few times, so this is like version 20 of 20.

Code:
      <Area Left="23" Right="51" Top="231" Bottom="263">
         <TooltipText>Decision Height Test</TooltipText>
            <Cursor Type="Hand"/>
            <Click Repeat="Yes">
               (M:Event) 'LeftSingle' scmp 0 == 
                  1 (>L:RAD ALT TEST,bool)
                  1 (&gt;L:XMLSND161,enum)
                  1 (&gt;L:XMLSND157,enum)
               (M:Event) 'LeftRelease' scmp 0 == 
                  0 (>L:RAD ALT TEST,bool)
                  0 (&gt;L:XMLSND161,enum)
                  1 (&gt;L:XMLSND157,enum)
            </Click>
         </Area>
 
Last edited:
Oh scrappie....

Just found this. Confusion comes back in second wave.

So these logic statements are based on M:Events; if an M:Event occurs like this, then do this.

Code:
<MouseFlags>WheelUp+WheelDown+LeftDrag+LeftSingle+MoveRepeat+LeftRelease</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle'  scmi 0 == if{ (M:X) (&gt;L:ClickStart) }
        (M:Event) 'WheelUp'     scmi 0 == if{ (&gt;K:VOR1_OBI_INC) }
        (M:Event) 'WheelDown'   scmi 0 == if{ (&gt;K:VOR1_OBI_DEC) }
        (M:Event) 'LeftRelease' scmi 0 == if{ 0 (&gt;L:switch_course_select) }
        (M:Event) 'LeftDrag'    scmi 0 == if{ (M:X) (L:ClickStart) - 0 &lt;
        if{ (&gt;K:VOR1_OBI_DEC) -1 (&gt;L:switch_course_select) }
        els{ (&gt;K:VOR1_OBI_INC) 1 (&gt;L:switch_course_select) } }
 
What I need to know is how do you write a code of mevents so that something turns on and off. How do you get a L:var for instance to only be on when holding the mouse key down.

LeftSingle = executes only once, at the moment the user presses the mouse button.
LeftRelease = executes only once, at the moment the user releases the mouse button.

So, for example, if you want a light to be turned on when the mouse button is pressed, and remain on until the button is released, just code like:

Code:
(M:Event) 'LeftSingle'  scmi 0 == if{ 1 (>L:Light On,bool) }
(M:Event) 'LeftRelease'  scmi 0 == if{ 0 (>L:Light On,bool) }

After the first click, as long as you keep the button pressed, none of the two events will execute.

Tom
 
Thanks Tom,

I just found some old code that basically had this and created this;

Code:
      <Area Left="23" Right="51" Top="231" Bottom="263">
         <TooltipText>Decision Height Test</TooltipText>
            <Cursor Type="Hand"/>
		<Click Kind="LeftSingle+Leave">
		(M:Event) 'LeftSingle' scmp 0 == if{ 
                  1 (>L:RAD ALT TEST,bool)
                  1 (&gt;L:XMLSND161,enum)
                  1 (&gt;L:XMLSND157,enum)
                }
		(M:Event) 'LeftRelease' scmp 0 == if{ 
                  0 (>L:RAD ALT TEST,bool)
                }
                </Click>
         </Area>


However, the darn thing will continue to make click sounds when holding down the left mouse button, and when releasing, the orange flag in the RADAlt continues to show. The flag is controlled by 1 (>L:RAD ALT TEST,bool)

argh... how hard is it to make a simple Radar Altimeter. Makes me want to just... just... I picked a bad time to stop sniffing glue.
 
FOUND IT!!!!!!!!! woo hoooo....

I needed 'Leave', not 'LeftRelease'. I found some old code that had been modified and wasn't cleaned up, (for my example).

I thought, 'Release' might be different from 'Leave', and it was. Looked around some more in the FS9 GPS code script and sure enough. Now it works!


Nothing like a nice 'crickie crickie' sound and flag function.
 
This you might useful also. It's the steward's light on the OH panel for the 10. When the steward calls the light comes on and extinguishes shortly after the message.
When the captain wants to call the steward he presses in the light switch and the light comes on while the switch remains pressed in. So there are two positions for the light whether the switch is pressed in or not. also when eithe the steward or the Captain calls there is a bing which repeats if the Captain holds the switch in.

Code:
<Gauge Name="Cabin Call" Version="1.0">
<Element>
      <Select>
         <Value>(L:CABIN CALL,number)</Value>
         <Case Value="0">
            <Image Name="ccallout.bmp"/>  [COLOR="Red"]<--- Switch normal[/COLOR]
         </Case>
         <Case Value="1">
            <Image Name="ccallin.bmp"/>  [COLOR="Red"]<--- Switch pressed in[/COLOR]
         </Case>
      </Select>
   </Element>

<Element>
      <Select>
         <Value>(L:CABIN CALL,number)</Value>         
         <Case Value="1">
            <Image Name="AMBER_ON_ON.bmp" Bright="Yes"/> [COLOR="Red"]<-- amber light if switch pressed in[/COLOR]
         </Case>
      </Select>
   </Element>

<Element>
      <Select>
        <Value>
     (L:CAB LIGHT 2,number) (P:local time, seconds) &gt; |
   </Value>         
         <Case Value="1">
            <Image Name="AMBER_STEW_ON_ON.bmp" Bright="Yes"/> [COLOR="Red"]<-- amber light if steward calls[/COLOR]
         </Case>
      </Select>
   </Element> 



<Mouse>  [COLOR="Red"]<-- dings repeatedly depending for how long the switch is pressed in and light stays on for duration[/COLOR]
         <Tooltip>Cabin Call</Tooltip>
         <Cursor Type="Hand"/>
	<Click Kind="LeftSingle+LeftRelease">
            (M:Event) 'LeftSingle' scmp 0 == if{ (L:CABIN CALL,number) ! (&gt;L:CABIN CALL,number)
     (L:CABIN CALL,number) 1 ==
2 (>L:Sound_attend2a,enum)
1 (>L:CAB LIGHT ON,number) }
            (M:Event) 'LeftRelease' scmp 0 == if{ (L:CABIN CALL,number) ! (&gt;L:CABIN CALL,number)
     (L:CABIN CALL,number) 1 ==
0 (>L:Sound_attend2a,enum)
i0 (>L:CAB LIGHT ON,number) }
        </Click>	
   </Mouse>
</Gauge>

vololiberista
 
I include +LeftDrag as a test also because that will prevent the problem of having your "push to test" button getting stuck should the mouse finger slip off the button during turbulence!

Example:
Code:
  <PartInfo>
    <Name>B350i_CCP_JOYSTICK_DOWN</Name>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 == 
           if{ -1 (>L:0x110EF,bool) 0x110F0 (>L:EVENT,enum) 1 (>L:XMLSND2,bool) }

        (M:Event) 'LeftRelease' scmp 0 == 
        (M:Event) 'LeftDrag' scmp 0 == or 
            if{ 0 (>L:0x110EF,bool) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Thanks guys. Storing these to notes.

Some ingenious coding work.

Finally I have grasped the whole 'm:event' thing...
 
Tom, I can almost half way answer that, yes. He was saying that's why he had to code them a certain way was for multiplayer/dual controls, from what he said.
 
Thanks Bill, I thought that.

I wonder the reason he doesn't use a true event instead (like ROTOR_BRAKE in airplanes).

Tom
 
Back
Top