FS2004 Gauges to trigger playing sounds

Uff... I was expecting a problem with the sound file integrity itself. However, try to isolate the problem: make a simple gauge with the 2 way switch where you only trigger the sound using pertinent variables and logic. Test both cases, where you remove TOGGLE and then with it. If the problem persist, I've got no idea what is causing it :confused:
 
Trying to make a simple 2D push & release button with sound. Using the following code:

XML:
    <Element>

    <Position>
      <Select>
         <Value>(L:BUTTON,bool)</Value>
         <Case Value="0">
           <Image Name="Released.bmp">
         </Case>
         <Case Value="1">
            <Image Name="Pushed.bmp">
         </Case>
      </Select>
    </Element> 

  <Mouse>                     
        <Area>   
         <Tooltip>BUTTON</Tooltip>
                <Cursor Type="Hand"/>
      <Click Kind="LeftSingle+LeftRelease+Leave">
                (M:Event) 'LeftSingle' scmp 0 ==
                if{
                    1 (&gt;L:BUTTON,bool)
                    1 (&gt;L:PushedSound,number)
                  }

                (M:Event) 'LeftRelease' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  }

                (M:Event) 'Leave' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  } 
        </Click>
        </Area>       
</Mouse>
It works but with some glitches. First If I do a quick mouse click on the button the Released.bmp bitmap won't change to Pushed.bmp as it should. However the 2 sounds work almost perfectly. I have to firmly press and hold the left mouse button to see it changing the bitmaps. Did not test it with another mouse so could it be just a mouse problem?

Second when I hold the left mouse button for some time the PushedSound starts playing as a loop. Could it be fixed by adding some code?

Any help would be appreciated!
 
to the first, it's clear. There is a release and leave

for example some excerpt of a gauge

Code:
    <Area Left="0" Top="0" Right="29" Bottom="29">
    <Tooltip ID=""> AP Off </Tooltip>
    <Cursor Type="Hand"/>
     <Click Kind="LeftSingle+RightSingle+Leave" Repeat="Yes">
      (M:Event)
      'LeftSingle' scmp 0 ==
      (L:AP_Disc_BT,number) 0 ==
      &amp;&amp;
      if{
        1 (&gt;L:AP_Disc_BT,number)
        1 (&gt;L:DSD_TECH_Button_SD,number)
        }
      (M:Event)
      'Leave' scmp 0 ==
      if{
        2 (&gt;L:AP_Disc_BT,number)
        }
     </Click>
    </Area>
  </Mouse>

+++give this in an element ++++++++++++++++++++++++++++

<!-- Reset Button sound -->
      (L:AP_Disc_BT,number) 2 ==
      if{
        (L:DSD_TECH_Button_SD,number) 0 ==
        if{
          0 (&gt;L:AP_Disc_BT,number)
          1 (&gt;L:DSD_TECH_Button_SD,number)
          }
        }
adapt the code
You get also two clicks
 
Now doing a 6 position knob switch that should toggle VOR1 / ADF1 and VOR2 / ADF2 ident audio signal - the last 2, VOR and ADF combined in one and swapped by switches 1 and 2, see the image below:
panel.jpg

Default positions are marked by 0. Also the signal is toggled ON/OFF by switch 3. The Knob Switch code works perfectly:
XML:
        <Area>            <Tooltip></Tooltip>                  <Cursor Type="UpArrow"/>                  <Click Kind="LeftSingle" Repeat="No" MouseWheelFlip="No">                       (M:Event) 'LeftSingle' scmp 0 ==                          if{                              (L:KNOB,number) ++ 5 min (&gt;L:TRMODE,number)                              <!-- Knob Switch Sound -->                              1 (&gt;L:KNOBSOUND,number)                             }                      </Click>          </Area>                                              <Area>            <Tooltip></Tooltip>                  <Cursor Type="DownArrow"/>                  <Click Kind="LeftSingle" Repeat="No" MouseWheelFlip="No">                       (M:Event) 'LeftSingle' scmp 0 ==                          if{                              (L:KNOB,number) -- 0 max (&gt;L:TRMODE,number)                              <!-- Knob Switch Sound -->                              1 (&gt;L:KNOBSOUND,number)                             }                                         </Click>          </Area>
I added the following code:
XML:
    <Element>       <Select>        <Value>                          (L:KNOB,number) 4 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH1,bool) &amp;&amp;                          if{ (&gt;K:RADIO_VOR1_IDENT_ENABLE)                              }                           els{                          (&gt;K:RADIO_VOR1_IDENT_DISABLE) }                           (L:KNOB,number) 4 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH1,bool) ! &amp;&amp;                          if{ (&gt;K:KEY_RADIO_ADF_IDENT_ENABLE)                              }                           els{                          (&gt;K:KEY_RADIO_ADF_IDENT_DISABLE) }                           (L:KNOB,number) 5 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH2,bool) &amp;&amp;                          if{ (&gt;K:RADIO_VOR2_IDENT_ENABLE)                              }                           els{                          (&gt;K:RADIO_VOR2_IDENT_DISABLE) }                                                  (L:KNOB,number) 5 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH2,bool) ! &amp;&amp;                          if{ (&gt;K:KEY_RADIO_ADF2_IDENT_ENABLE)                              }                           els{                          (&gt;K:KEY_RADIO_ADF2_IDENT_DISABLE) }                                </Value>       </Select>      </Element>

Looks like VOR1 and VOR2 give a signal when switching / swapping but ADFs do not. I also tried KEY_RADIO_ADF2_IDENT_TOGGLE / KEY_RADIO_ADF_IDENT_TOGGLE. It works to some extent but the signal is interrupted sometimes and won't turn off.

Any help would be appreciated!
 
Last edited:

tgibson

Resource contributor
Load the MDL into ModelConverterX. If it is an FS2004 model set the general model to 0. You can figure out which part it is by using the Hierarchy Editor - turn on Highlight Selected. Click on the parts in the left box and when the desired part turns read, read the Animation name in the right box. This is the one you are looking for in the modeldef.xml file. Then click on the Modeldef.xml Editor button to see the code.

Hope this helps,
 
Load the MDL into ModelConverterX.
Tom thanks! Got an error when loading it. But I asked a guy that have access to the model source and he gave it to me.

Have a question about XML syntax for OR operator. I need TRUE for variables A and any of B or C.
Code:
A B C || &amp;&amp;
Is this correct? And for example A and any of B or C or D or E. That's:
Code:
A B C || D || E || &amp;&amp;
That's for example for a switch (ON/OFF) and any of the power sources: Battery, or GPU, or APU, or Engine generators.
 
Last edited:
the second is easy.
Adding (L:BUTTON,bool) 0 == works perfectly for a simple push & release button, no loop, but what if it is STAB TRIM like this one:
XML:
  <Mouse>                     
        <Area>   
         <Tooltip>STAB TRIM</Tooltip>
                <Cursor Type="UpArrow"/>
      <Click Kind="LeftSingle+LeftRelease+Leave">
                (M:Event) 'LeftSingle' scmp 0 ==
                if{
                    -1 (&gt;L:BUTTON,bool) (L:Stabilizer, degree) 0 &lt;
                    1 (&gt;L:PushedSound,number)
                        if{
                            (L:Stabilizer, degree) 0.05 + (&gt;L:Stabilizer, degree)
                          }
                  }

                (M:Event) 'LeftRelease' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  }

                (M:Event) 'Leave' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  }
        </Click>
        </Area>       
</Mouse>
Adding (L:BUTTON,bool) 0 == will have me click each time I want to move the STAB up or down (similar code). Thanks in advance for the help.
 
Top