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

Deceleration Zone 'Ding' Alert

Messages
10,163
Country
us-arizona
Hey guys,


I have a problem.

I need a 'ding' to occur, one time, when decelerating through 85 knots to let the pilot know the plane is entering the 'yellow' airspeed zone.

I have tried a 'plethra' of combinations of code. This one dings once, but only through the accelleration zone. When decelling back through it, it will not ding.

Perhaps a ding timer? Like, if the ding has occurred, it will clear itself after say 3 or 5 seconds? (Power out will need to come back on after a bit).

but... I dont know how to write timers that well yet, so I have no idea how that would be written.

Any advice? :/

Code:
   <Element>
            <Select>
            <Value>
                (L:AVEsound_played77,bool) 0 ==
                (A:VELOCITY BODY Z,knot) 85 &lt;
                (A:SIM ON GROUND,bool) 0 ==
                and and
                if{
                1 (&gt;L:XMLSND78,enum) 
                1 (&gt;L:AVEsound_played77,bool) 
                }
                (L:AVEsound_played77,bool) 1 ==
                (A:VELOCITY BODY Z,knot) 85 &gt;
                (A:SIM ON GROUND,bool) 1 ==
                and and
                if{
                3 (&gt;L:AVEsound_played77,bool) 
            </Value>
            </Select>
   </Element>


<Element>
<Select>
<Value>
(L:AVEsound_played77,bool) 0 ==
(A:VELOCITY BODY Z,knot) 85 &lt;
(A:SIM ON GROUND,bool) 0 ==
and and
if{
1 (&gt;L:XMLSND78,enum)
1 (&gt;L:AVEsound_played77,bool)
}
(L:AVEsound_played77,bool) 1 ==
(A:VELOCITY BODY Z,knot) 85 &gt;
(A:SIM ON GROUND,bool) 1 ==
and and
if{
3 (&gt;L:AVEsound_played77,bool)
</Value>
</Select>
</Element>



Bill of the giant eyebrow developer race...
 
Your logic is inverted, so your has_played variable is being set incorrectly...

Code:
   <Element>
            <Select>
            <Value>
                (L:AVEsound_played77,bool) 0 ==
                (A:VELOCITY BODY Z,knot) 85 &gt;
                (A:SIM ON GROUND,bool) 1 ==
                and and
                if{
                1 (&gt;L:AVEsound_played77,bool) 

                (L:AVEsound_played77,bool) 1 ==
                (A:VELOCITY BODY Z,knot) 85 &lt;
                (A:SIM ON GROUND,bool) 0 ==
                and and
                if{
                1 (&gt;L:XMLSND78,enum) 
                0 (&gt;L:AVEsound_played77,bool) 
                }
            </Value>
            </Select>
   </Element>

Follow the logic chain as shown above.

Pilot accelerates down the runway, passes 85 knots, because the sound_played = 0, plays the ding, then sets sound_played equal to 1.

Pilot decreases power, gets slower than 85 knots, since sound_played = 1, the ding will play, and the sound_played is reset to 0 again.

The only problem with the above logic is that if the pilot accelerates past 85 knots again, the ding will NOT play because your logic is such that it will only work when the a/c is on the ground!

Personally, I'd remove the sim on ground check entirely.
 
Thanks Bill.

I took your advice and changed it around. It still didnt work, and I remembered Chris' trick with 'rng' and set a 1 Knot differential range, 84 to 85 knots, and that works nicely.


I did separate everything out into their own Elements and also created a rest-on-ground. (I also found a missing if bracket, which I placed back in the mix).

The idea for sim on ground was that it will only ding in the sky, letting you know its getting into the yellow zone, a pleasant reminder but with not much shrill to it.


Working code, which is overly sophisticated and probably could lose about 50% of it, but hey, Im still learning...


Code:
<!--  ====================================================  DING SOUND AT 85 < KNOTS  -->

   <Element>
            <Select>
            <Value>
                (L:AVEsound_played77,bool) 1 ==
                (A:VELOCITY BODY Z,knot) 96 &gt;
                and
                if{
                0 (&gt;L:AVEsound_played77,bool) 
                3 (&gt;L:XMLSND78,enum) 
                1 (&gt;L:XMLSND78,enum) 
                }
            </Value>
            </Select>
   </Element>

<!--  DING SOUND AT 85 < KNOTS  -->
   <Element>
            <Select>
            <Value>
                (L:AVEsound_played77,bool) 1 ==
                (A:VELOCITY BODY Z,knot) 85 &gt;
                (A:SIM ON GROUND,bool) 1 ==
                or or 
                if{
                0 (&gt;L:AVEsound_played77,bool) 
                0 (&gt;L:XMLSND78,enum) 
                }
            </Value>
            </Select>
   </Element>

<!--  DING ON DESCENT  -->
   <Element>
            <Select>
            <Value>
                (L:AVEsound_played77,bool) 0 ==
                84 85 (A:VELOCITY BODY Z,knot) rng
                (A:SIM ON GROUND,bool) 0 ==
                and and
                if{
                1 (&gt;L:XMLSND78,enum) 
                1 (&gt;L:AVEsound_played77,bool) 
                }
            </Value>
            </Select>
   </Element>

<!--  RESET ON GROUND  -->
   <Element>
            <Select>
            <Value>
                (A:SIM ON GROUND,bool) 1 ==
                if{
                0 (&gt;L:XMLSND78,enum) 
                0 (&gt;L:AVEsound_played77,bool) 
                }
            </Value>
            </Select>
   </Element>



<!-- ==================================================== DING SOUND AT 85 < KNOTS -->

<Element>
<Select>
<Value>
(L:AVEsound_played77,bool) 1 ==
(A:VELOCITY BODY Z,knot) 96 &gt;
and
if{
0 (&gt;L:AVEsound_played77,bool)
3 (&gt;L:XMLSND78,enum)
1 (&gt;L:XMLSND78,enum)
}
</Value>
</Select>
</Element>

<!-- DING SOUND AT 85 < KNOTS -->
<Element>
<Select>
<Value>
(L:AVEsound_played77,bool) 1 ==
(A:VELOCITY BODY Z,knot) 85 &gt;
(A:SIM ON GROUND,bool) 1 ==
or or
if{
0 (&gt;L:AVEsound_played77,bool)
0 (&gt;L:XMLSND78,enum)
}
</Value>
</Select>
</Element>

<!-- DING ON DESCENT -->
<Element>
<Select>
<Value>
(L:AVEsound_played77,bool) 0 ==
84 85 (A:VELOCITY BODY Z,knot) rng
(A:SIM ON GROUND,bool) 0 ==
and and
if{
1 (&gt;L:XMLSND78,enum)
1 (&gt;L:AVEsound_played77,bool)
}
</Value>
</Select>
</Element>

<!-- RESET ON GROUND -->
<Element>
<Select>
<Value>
(A:SIM ON GROUND,bool) 1 ==
if{
0 (&gt;L:XMLSND78,enum)
0 (&gt;L:AVEsound_played77,bool)
}
</Value>
</Select>
</Element>
 
This is completely unnecessary:

0 (&gt;L:XMLSND78,enum)

Once the sound gauge has played the sound once, IT resets the L:var to 0 automatically. :D

It doesn't hurt mind you, it's just that it doesn't actually DO anything that hasn't already been done. :cool:
 
Here's some simple stuff in FS9 along the lines you want that seems to work ok:-
the first one plays a msg from the cabin "Cabin pre-landing check is complete and escape slides in position" + it activates the stewards light on the OH panel.

The second plays "gear up"
the third and fourth play "80 knots" during the take-off run and "60 knots" during the landing roll.
vololiberista
Code:
<Element>
    <Select>
     <Value>
(L:sound_played,bool) 0 == (A:RADIO HEIGHT,FEET) 6700 &lt; and (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:ZULU TIME, seconds) 20.5 + (>L:CAB LIGHT 2,number) and 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 and if{ 1 (>L:Sound_Gear Up,number) 1 (>L:sound_played2,bool) and and }
      </Value>
    </Select>
   </Element>

<Element>
    <Select>
      <Value>
(L:sound_played3,bool) 0 == (A:SIM ON GROUND, bool) 1 == and (A:AIRSPEED INDICATED,knots) 76 &gt; (A:Turb eng1 N2, percent) 93 &gt; and and if{ 1 (>L:Sound_80k,number) 1 (>L:sound_played3,bool) and and }
      </Value>
    </Select>
   </Element>

<Element>
    <Select>
      <Value>
(L:sound_played4,bool) 0 == (A:SIM ON GROUND, bool) 1 == and (A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent) 95 &gt; (A:AIRSPEED INDICATED,knots) 65 &lt; and and
if{ 1 (>L:Sound_60k,number) 1 (>L:sound_played4,bool) and }
      </Value>
    </Select>
   </Element>
 
Many thanks Vololiberista. Copying them to my archives.


Bill,

For some reason, on my code, the 'ding' just kept playing. It wouldnt reset itself, which as I think about it, must have been the flaw in my code, as it should have locked once it played once, but it was looping. As soon as it was out of the 'zone', the beeping stopped. When it was in the zone, it just kept looping for some reason. My zero was intended to help stop it, but didnt work.



Bill
 
Nice! a timer!


(L:sound_played,bool) 0 == (A:RADIO HEIGHT,FEET) 6700 &lt; and (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:ZULU TIME, seconds) 20.5 + (>L:CAB LIGHT 2,number) and and }


Bill
 
Out of curiosity, what's the last "and and " for?
To me it seems to do nothing in the code section you posted.

Grt
Willem
 
Out of curiosity, what's the last "and and " for?
To me it seems to do nothing in the code section you posted.

Grt
Willem

Nothing whatever. There's several such non-functioning conjunctions in the script.
 
What counts to me and my pilots that will be flying my creations are that the script works. Thats the bottom line.

We all learn better, cleaner ways of doing things as we work these tools and things more and more.

What would be interesting, is if taking the 'and and' caused it to 'not' function. ;)


Thanks though everyone for the help.

VoloLibirista, it is one cool feeling when all the dings and sounds are happening during a flight. When my '85 knots barrier ding' occurs, my eyes dialate, my eyebrows stand erect, a chill runs up my spine, and a grin creeps across my face. LOVE IT!!!!
 
In my VC10 the 80knts call comes seconds after full throttle!!!!!!
How's that for "as real as it gets!"
vololiberista
 
WhWhat would be interesting, is if taking the 'and and' caused it to 'not' function. ;)

Bill, the long and short of is that the 'and' and 'or' conjunctions simply do nothing at all unless they come before an if{ } statement.

Having an 'and' or an 'or' inside of an if{ } statement makes no sense at all, unless there's also another nested if{ } statement in there as well.

Mind you, it doesn't harm anything at all, unless being confusing and hard to read causes mental harm!
 
Bill, the long and short of is that the 'and' and 'or' conjunctions simply do nothing at all unless they come before an if{ } statement.

Having an 'and' or an 'or' inside of an if{ } statement makes no sense at all, unless there's also another nested if{ } statement in there as well.

Mind you, it doesn't harm anything at all, unless being confusing and hard to read causes mental harm!


Doing it your way Bill I get incorrect functions. For example if I take away the and from here:-
Code:
<Element>
    <Select>
      <Value>
(L:sound_played4,bool) 0 == (A:SIM ON GROUND, bool) 1 == and (A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent) 95 &gt; (A:AIRSPEED INDICATED,knots) 65 &lt; and and
if{ 1 (>L:Sound_60k,number) 1 (>L:sound_played4,bool) [COLOR="Red"]and [/COLOR]}
      </Value>
    </Select>
   </Element>

then when I open the aircraft file which is always a "cold" cockpit the first thing that happens is a "60kts call!".
I do however have a recurrent problem with the following code:-
Code:
<Element>
    <Select>
     <Value>
(L:sound_played,bool) 0 == (A:RADIO HEIGHT,FEET) 6700 &lt; and (L:Cabin_Rate_Select,number) 0 &lt; and if{ 1 (>L:Sound_mes3,number) 1 (>L:sound_played,bool) 1 (>L:CABIN CALL,number) [COLOR="Red"](P:ZULU TIME, seconds) 20.5 + (>L:CAB LIGHT 2,number)[/COLOR] and and }
</Value>
    </Select>
   </Element>
which is when tested in flight all works, but only once. Thereafter the stewards's light won't illuminate.
vololiberista
 
Not to change the subject, but I cant believe how difficult it has been to create a code that activates a sound 'one time' each time a scenario occurs. It should be easy.

My sounds system for instance states to play something once, one time, and I have a secondary command to shut down sounds. But if I set up a code that plays a sound when 'this happens', I get a loop effect where the sound just keeps playing over and over. Getting it to play once has been quite an endeavor. I cant see why this is occuring. Its such an easy and basic command. Play this once when this happens....

I have tried 'do this, then run 'stop all sounds' and it loops through that still. I have tried adding 'end' in my logic, and it still loops the sound. I just dont get it....

And... its only with sounds.



Bill
 
Not to change the subject, but I cant believe how difficult it has been to create a code that activates a sound 'one time' each time a scenario occurs. It should be easy.

My sounds system for instance states to play something once, one time, and I have a secondary command to shut down sounds. But if I set up a code that plays a sound when 'this happens', I get a loop effect where the sound just keeps playing over and over. Getting it to play once has been quite an endeavor. I cant see why this is occuring. Its such an easy and basic command. Play this once when this happens....

I have tried 'do this, then run 'stop all sounds' and it loops through that still. I have tried adding 'end' in my logic, and it still loops the sound. I just dont get it....

And... its only with sounds.



Bill


Yes, this was my problem too! And, in fact when I followed the other Bill's advice I also got recurring sounds. What I posted here "does" work!! Even though it is technically "incorrect". (I did however, take away the ands within the if statements. (thanks for that advice). I also sol ved the problem above. ZULU TIME should have been local time!
vololiberista
 
What is the initial value of all L:variables when the aircraft is first loaded?
If you answered ZERO you win a Gold Star.

Now, think carefully about your conditions:

(L:sound_played4,bool) 0 ==
(A:SIM ON GROUND, bool) 1 == and
(A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent) 95 &gt;
(A:AIRSPEED INDICATED,knots) 65 &lt; and and

if{ 1 (>L:Sound_60k,number) 1 (>L:sound_played4,bool) and }

  1. When first loaded, (L:sound_played4,bool) 0 == will be TRUE
  2. When first loaded, (A:SIM ON GROUND, bool) 1 == will be TRUE
  3. When first loaded, (A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent) 95 &gt; might be TRUE if this is part of your "cold and dark" saved file.
  4. When first loaded, (A:AIRSPEED INDICATED,knots) 65 &lt; will be TRUE

Since all of the above conditions are TRUE, obviously the entire statement is also TRUE, so of course the "sound will play!"

The extra "and" marked in red in the "action list" does absolutely nothing. It is simply ignored.
 
When I see these in stacks, its easier for me to read, and I think I see now whats going on.


Conditions get 'ands', and the ands go at the back of the stack of conditions.

Commands do not get 'ands'.

When I read through a flat command string (instead of stacks), I cannot see how things are working.


For those that are new to gauge code, commands will have their 0 and 1 settings (on and off) at the front, while 'conditions' are set at the back of each condition, and have an 'operator' code with it, such as ! , &gt; , > , == , or , etc....


(L:sound_played4,bool) 0 ==
(A:SIM ON GROUND, bool) 1 ==
(A:TRAILING EDGE FLAPS0 LEFT PERCENT, percent) 95 &gt;
(A:AIRSPEED INDICATED,knots) 65 &lt;
and and and
if{ 1 (>L:Sound_60k,number) 1 (>L:sound_played4,bool) }


I think that would be the right way to right it, though I do not know if this will get a 'single' ding, per the subject.
 
When I see these in stacks, its easier for me to read, and I think I see now whats going on.

Well, that is the way they should be written, at least while writing the script. You can always remove the carriage returns to "flatten" them if desired. I find that it makes the logic flow easier to see and understand!

Conditions get 'ands', and the ands go at the back of the stack of conditions.

While that is true, in reality just like "stacking" the conditions, it is far easier to construct your logic if the conjunctions are placed immediately after each "pair" that you wish to join.

IOW:
Code:
(condition1)
(condition2) conjunction
(condition3) conjunction
(condition4) conjunction
if{ actions }

I think that would be the right way to right it, though I do not know if this will get a 'single' ding, per the subject.

It will only play a single "ding" (or whatever sound you wish) once, but the problem is that it will -as remarked on above- also play once when loading the aircraft!

Also, once it has played "once" there's no logic to reset the lock variable!
 
Back
Top