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

Command; Do 'Once'

Messages
10,163
Country
us-arizona
Hey all,

Man, we had covered this in another thread and now I cannot find it.

I wish to make something occur 'one time' and instead, it just keeps going.

I have an auto-pressurization system on this plane. At 9,000 feet, a 'ding' should occur. Instead, the ding just begins blairing away, playing over and over and over in a large thunder.

Bill Leaming, you had figured out a nifty code that plays once, then resets. Is it possible you could show us how that is done again?


This is the 2D gauge XML I have for this;

Code:
            <Value>
                (A:PLANE ALTITUDE, feet) 9005 
                if{ (A:PLANE ALTITUDE, feet) 9005 ==
                1 (&gt;L:XMLSND56,enum) 
                if{ (A:PLANE ALTITUDE, feet) 9006 &gt;
                3 (&gt;L:XMLSND56,enum) }
                if{ (A:PLANE ALTITUDE, feet) 9004 &lt;
                3 (&gt;L:XMLSND56,enum) }
                }
            </Value>

That was supposed to kill it after it passed through 9005 feet.

or... 

            <Value>
                (A:PLANE ALTITUDE, feet) 9000 
                if{ (A:PLANE ALTITUDE, feet) 9000 
                1 (&gt;L:XMLSND56,enum) 
                }
            </Value>

I tried a few variations, but none worked, only repetition triggering.
 
Code:
<!-- Code to trigger the sound -->
(A:PLANE ALTITUDE, feet) 9000 >
(L:DING_PLAYED, bool ) 0 ==
and
if{
3 (&gt;L:XMLSND56,enum)
1 (&gt;L:DING_PLAYED, bool )
}

<!-- Code to stop the sound -->
(A:PLANE ALTITUDE, feet) 9005 >
(L:DING_PLAYED, bool ) 1 ==
and
if{
1 (&gt;L:XMLSND56,enum)
0 (&gt;L:DING_PLAYED, bool )
}

5 feet (between 9000 and 9005) is a pretty narrow window, you may need to make it a lot bigger to get satisfactory results.
Also, I am assuming that a value of 3 causes the sound to loop and a value of 1 stops the sound.
Remember, the 'if' statement has to come after the conditions that are triggering it.

Doug
 
Thanks Doug,

I am off to try this.

On my sound system, 1 plays once, 2 is loop mode, and 3 kills the sound if in loop mode.


Bill
 
I did this with the help of the Guru's on this site. It might give you some ideas as it's quite simple:-
The first plays a message from the cabin during descent and also turns a light on on the Captain's OH.
The second plays "Positive Climb --- Gear Up" justafter take-off.
vololiberista

Code:
<Gauge Name="Sounds" Version="1.0">
   <Element>
    <Select>
      <Value>
(L:sound_played,bool) 0 == (A:Indicated altitude, feet) 7000 &lt; (L:Cabin_Rate_Select,number) 0 &lt; and if{ 1 (>L:Sound_mes3,number) 1 (>L:sound_played,bool) 1 (>L:CABIN CALL,number) (P:local time, seconds) 20.5 + (>L:CAB LIGHT 2,number) and }
      </Value>
    </Select>
   </Element>

<Element>
    <Select>
      <Value>
(L:sound_played2,bool) 0 == (A:SIM ON GROUND, bool) 0 == (A:RADIO HEIGHT,FEET) 50 &gt; and if{ 1 (>L:Sound_Gear Up,number) 1 (>L:sound_played2,bool) and }
      </Value>
    </Select>
   </Element>
</Gauge>
 
Hey Volo Liberista,

That is the one! Brilliant. Many thanks Sir.


I condensed it into a stack from strings for others (like me) that are not as far along in gauges to see how it works more easily;



Code:
<Gauge Name="Sounds" Version="1.0">
   <Element>
    <Select>
      <Value>
      (L:sound_played,bool) 0 == 
      (A:Indicated altitude, feet) 7000 &lt; 
      (L:Cabin_Rate_Select,number) 0 &lt; and 
      if{ 
      1 (>L:Sound_mes3,number) 
      1 (>L:sound_played,bool) 
      1 (>L:CABIN CALL,number) 
      (P:local time, seconds) 20.5 + 
      (>L:CAB LIGHT 2,number) 
      and 
      }
      </Value>
    </Select>
   </Element>

<Element>
    <Select>
      <Value>
      (L:sound_played2,bool) 0 ==
      (A:SIM ON GROUND, bool) 0 == 
      (A:RADIO HEIGHT,FEET) 50 &gt; 
      and  
      if{ 
      1 (>L:Sound_Gear Up,number) 
      1 (>L:sound_played2,bool) and }
      </Value>
    </Select>
   </Element>
</Gauge>

May I ask how the time function works, how and why? quote; (P:local time, seconds) 20.5 +
 
Correct.

The issue is that the code was repeating/looping, continuing to call on the 1 XML sound file command.

Of course. I was pointing out that you were sending a "3" in your first example. Which actually does no harm, as it doesn't do anything at all! :rolleyes:
Code:
            <Value>
                (A:PLANE ALTITUDE, feet) 9005 
                if{ (A:PLANE ALTITUDE, feet) 9005 ==
                1 (&gt;L:XMLSND56,enum) 
                if{ (A:PLANE ALTITUDE, feet) 9006 &gt;
                3 (&gt;L:XMLSND56,enum) }
                if{ (A:PLANE ALTITUDE, feet) 9004 &lt;
                3 (&gt;L:XMLSND56,enum) }
                }
            </Value>
 
The
Code:
(P:local time, seconds) 20.5 +
is a timer for the Steward's light on the Captains OH. When the cabin contacts the flightdeck the light comes on and there is also a ding. The Captain cancels the light after the msg is played or if he is tooooooooooo busy the light self extinguishes after the 20 secs.
vololiberista
 
May I ask how the time function works, how and why? quote; (P:local time, seconds) 20.5 +
Code:
      (P:local time, seconds) 20.5 + 
      (>L:CAB LIGHT 2,number)

Bill, what's happening is that this script will take the current local time in seconds, add 20.5 to it, then initialize the result in the (L:CAB LIGHT 2,number) variable.

Presumably, in the annunciator light he's then using that as one of the operands in an if{ xxx } statement:

(P:local time, seconds) (L:CAB LIGHT 2,number) &gt; if{ xxx }

Since this happens "almost instantly", he's comparing "present time" with the "future time..." of 20.5 seconds.
 
Many thanks Bill for explaining this.

I just spent 2 hours trying to get it to work, and you posted the second half of the light string code which will make this work. I am greatful...

Since this happens "almost instantly", he's comparing "present time" with the "future time..." of 20.5 seconds.

I just had a feeling that Quantum Mechanics and time variables would have a play in the grand 'Schema' of things..... :-}
 
My fault for giving you half the story, sorry!
This is the code for the Steward's light
vololiberista
Code:
<Gauge Name="Cabin Call light" Version="1.0">
   <Element>
      <Select>
        <Value>
     (L:CAB LIGHT 2,number) (P:local time, seconds) &gt;
     (L:CABIN CALL,number)
and
</Value>
         <Case Value="0">
            <Image Name="AMBER_OFF.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="AMBER_ON.bmp" Bright="Yes"/>
         </Case>
      </Select>
   </Element> 
</Gauge>

And this is the door open light which when closed gives the cabin crew time to attach the escape slides and then call the Captain.
Code:
<Gauge Name="Doorcontrol" Version="0.1">
<Update>
(L:Monitor_door_sound, bool)
if{ (L:Sound_door,enum) ! (A:CANOPY OPEN,enum) 0 == and if{ 0 (>L:Monitor_door_sound, bool) 1 (>L:Sound_mes1,enum) 1 (>L:CABIN CALL,number) (P:local time, seconds) 20.5 + (>L:CAB LIGHT 2,number) and }
}
</Update>
<Element>
		<Visible>(A:CANOPY OPEN,enum) 0 &gt; (A:CANOPY OPEN,enum) 1 &lt; &amp;&amp;</Visible>
		<Image Name="BLUE_ON.bmp" Bright="Yes"/>
		<Position X="4.5" Y="0.5"/>
</Element>
<Element>
		<Visible>(A:CANOPY OPEN,enum) 1 ==</Visible>
		<Image Name="RED_ON2.bmp"  Bright="Yes"/>
		<Position X="1.5" Y="52.0"/>
</Element>
	
	<Mouse>
<Help_none/>

<!-- Main Exit - Button -->
	<Area Left="6" Top="6" Width="30" Height="65">
		 <Click> (&gt;K:TOGGLE_AIRCRAFT_EXIT)  1 (>L:Sound_door,enum) 1 (>L:Monitor_door_sound, bool)</Click>
		<Cursor Type="Hand"/>
    </Area>
</Mouse>
</Gauge>

This is the code for the safety video
Code:
<Gauge Name="Safety Vid" Version="1.0">
<Image Name="SWAP.bmp"/>
<Update>
(L:Monitor_Sound, bool)
if{ (L:Sound_BAsafety,enum) ! if{ 0 (>L:Monitor_Sound, bool) 1 (>L:Sound_mes2,enum) 1 (>L:CABIN CALL,number) (P:local time, seconds) 20.5 + (>L:CAB LIGHT 2,number) and }
}
</Update>

<Element>
      <Select>
         <Value>(L:safety,number)</Value>
         <Case Value="0">
            <Image Name="SWAP.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="SWAP.bmp"/>
         </Case>
      </Select>
   </Element>

   <Mouse>
<Tooltip>Cabin Safety Briefing</Tooltip>
  <Cursor Type="Hand" /> 
         <Click>1 (>L:Sound_BAsafety,enum)
1 (>L:Monitor_Sound, bool)
</Click>
   </Mouse>
</Gauge>

So the effect is that I have three cabin calls that "appear" to occur automatically
 
Last edited:
Many thanks VL,

I'll pour through these and see how they work.

I tried all day yesterday to get that darn thing to work. Amazing how many ways one can write code and 'still' not be able to get it to function correctly...

It sounds like your airliner is going to have one fantastic layout of amazing 'workings'. How do you know so much about this aircraft? Are you a former pilot of one?

Bill
 
Bill, there always have been an infinite number of ways to write crap, but usually only one way to write it correctly... :eek:
 
Many thanks VL,

I'll pour through these and see how they work.

I tried all day yesterday to get that darn thing to work. Amazing how many ways one can write code and 'still' not be able to get it to function correctly...

It sounds like your airliner is going to have one fantastic layout of amazing 'workings'. How do you know so much about this aircraft? Are you a former pilot of one?

Bill

The answer is "yes!" I started my career on the VC10. I have been re-activating, adding, creating new switches, lights and gauges etc to make the model as close as possible to the 634 page manual!!!! But, I could not have done some of the 100+ additions without the help of the Guru's here!!
It now takes 35 mins from entering the cockpit to take-off from T5 to rwy 27L at Heathrow. Much more realistic! I have only the hydraulic panel and doppler left to model. If ever you want to know how it is to fly a high performance heavy try the VC10. No other a/c can take-off from Cuzco for example at max AUW of 335,000lbs!
vololiberista
 
The answer is "yes!" I started my career on the VC10. I have been re-activating, adding, creating new switches, lights and gauges etc to make the model as close as possible to the 634 page manual!!!! But, I could not have done some of the 100+ additions without the help of the Guru's here!!
It now takes 35 mins from entering the cockpit to take-off from T5 to rwy 27L at Heathrow. Much more realistic! I have only the hydraulic panel and doppler left to model. If ever you want to know how it is to fly a high performance heavy try the VC10. No other a/c can take-off from Cuzco for example at max AUW of 335,000lbs!
vololiberista

Very cool! I look forward to flying your sophisticated creation!
 
Back
Top