How to play a sound only once?

Hiya,

Trying to make "sound" gauge. Want to play the sound when the exit is opened.

With this code:


<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document
Type="AceXML"
version="1,0"
id="AvadTest">
<Descr>AceXML Document</Descr>
<Filename>marcel_extra_sound.xml</Filename>
<SimGauge.Gauge id="marcel_extra_sound" ArtDirectory=".">
<FloatPosition>0.000,0.000</FloatPosition>
<Update id="Update">
<Frequency>999999</Frequency>
<Script>(A:EXIT OPEN:0,percent) 15 &gt; (A:EXIT OPEN:0,percent) 16 &lt; and if{ 1 (&gt;L:CA_Sound00) }</Script>
</Update>
</SimGauge.Gauge>
</SimBase.Document>


Now the sound will also play when the exit is closed.
I do not want that :) Is there a way to do that? So only play a sound when the exit is opened and NOT when it's closed?

Thanks,

Marcel
 
Hi Chris,

Thanks for the reply, i must admit i've very new to XML programming.
Any change you have the "code" for what you describe? :rolleyes:

Thanks,

Marcel
 

tgibson

Resource contributor
Most of us here use the FS2004 XML format instead of the FSX (Aces) format - much easier to read and to code.
 
Ok, since we're all under house arrest at the moment and I've got plenty of time ... :p

XML:
<Gauge Name="ExitOpenSound" Version="1.0">

  <!-- Set Flag if door opening -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:0,percent) 10 &gt; (L:DoorFlag,bool) 0 == &amp;&amp; if{ 1 (&gt;L:DoorFlag,bool) }</Value>
      </Select>
  </Element>

  <!-- Reset Flags if door closed -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:0,percent) 5 &lt; (L:DoorFlag,bool) 1 ==  &amp;&amp; if{ 0 (&gt;L:DoorFlag,bool) 0 (&gt;L:PlaySound,bool) 0 (&gt;L:SoundOnce,bool) }</Value>
      </Select>
  </Element>

  <!-- Let sound play if door opened -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:0,percent) 15 &gt; (L:DoorFlag,bool) 1 == &amp;&amp; if{ 1 (&gt;L:PlaySound,bool) }</Value>
    </Select>
  </Element>
 
  <!-- Play the sound -->
 <Element>
    <Select>
      <Value>(L:PlaySound,bool) 1 == (L:SoundOnce,bool) 0 == &amp;&amp; if{ 1 (&gt;L:TestSound,Number) 1 (&gt;L:SoundOnce,bool) }</Value>
    </Select>
  </Element>

</Gauge>
I'm using Doug Dawson's sound gauge, I assume you are as well, so the L:SoundOnce flag is to do just that.
 
Hi Chris,

Thanks a lot , and yes indeed i use Doug Dawson's sound gauge.

Modified it to have two warnings, works like a charm!!

<Gauge Name="ExitOpenSound" Version="1.0">

Code:
<Gauge Name="ExitOpenSound" Version="1.0">

  <!-- Credits and Thanks to Chris at www.fsdeveloper.com -->
 
  <!-- PASS DOOR WARNING -->
 
  <!-- Set Flag if door opening -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:0,percent) 10 &gt; (L:Door0Flag,bool) 0 == &amp;&amp; if{ 1 (&gt;L:Door0Flag,bool) }</Value>
      </Select>
  </Element>

  <!-- Reset Flags if door closed -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:0,percent) 5 &lt; (L:Door0Flag,bool) 1 ==  &amp;&amp; if{ 0 (&gt;L:Door0Flag,bool) 0 (&gt;L:Play0Sound,bool) 0 (&gt;L:Sound0Once,bool) }</Value>
      </Select>
  </Element>

  <!-- Let sound play if door opened -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:0,percent) 15 &gt; (L:Door0Flag,bool) 1 == &amp;&amp; if{ 1 (&gt;L:Play0Sound,bool) }</Value>
    </Select>
  </Element>
 
  <!-- Play the sound -->
 <Element>
    <Select>
      <Value>(L:Play0Sound,bool) 1 == (L:Sound0Once,bool) 0 == &amp;&amp; if{ 1 (&gt;L:CA_Sound00) 1 (&gt;L:Sound0Once,bool) }</Value>
    </Select>
  </Element>
 
  <!-- CARGO DOOR WARNING -->
 
  <!-- Set Flag if door opening -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:1,percent) 10 &gt; (L:Door1Flag,bool) 0 == &amp;&amp; if{ 1 (&gt;L:Door1Flag,bool) }</Value>
      </Select>
  </Element>

  <!-- Reset Flags if door closed -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:1,percent) 5 &lt; (L:Door1Flag,bool) 1 ==  &amp;&amp; if{ 0 (&gt;L:Door1Flag,bool) 0 (&gt;L:Play1Sound,bool) 0 (&gt;L:Sound1Once,bool) }</Value>
      </Select>
  </Element>

  <!-- Let sound play if door opened -->
  <Element>
    <Select>
      <Value>(A:EXIT OPEN:1,percent) 15 &gt; (L:Door1Flag,bool) 1 == &amp;&amp; if{ 1 (&gt;L:Play1Sound,bool) }</Value>
    </Select>
  </Element>
 
  <!-- Play the sound -->
 <Element>
    <Select>
      <Value>(L:Play1Sound,bool) 1 == (L:Sound1Once,bool) 0 == &amp;&amp; if{ 1 (&gt;L:CA_Sound01) 1 (&gt;L:Sound1Once,bool) }</Value>
    </Select>
  </Element>
</Gauge>
Thanks again!

For the ones wondering, just adding some PC-12 warning sounds to Carendao's PC-12.

Regards,

Marcel
 
Top