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

What am I doing wrong here?

Messages
10,163
Country
us-arizona
I am having a problem here just trying to get a sound to function when the doors are open. Its now become frustrating. I think I have tried 30 or 40 or far more variations of code and nothing has worked so far.

Psuedo code; Door open (true) + main power on = door ding sound (loop mode) until door is shut, (loop stops).


Door Condition (EXIT OPEN) and (EXIT CLOSED)

Power Condition

Door sound code string on/loop mode; 2 (>L:XMLSND64,enum)

Door Sound Terminate; 3 (>L:XMLSND64,enum)


I have tried <Value> only with a if/els.
I have tried adding <Case> with value of 1
I have tried everything I know, and dang if I can get it to work.....


Some versions tried.....

(A:EXIT OPEN,percent) 1 &gt;
1 (&gt;L:XMLSND64,enum)
and

(EXIT OPEN) if{ (EXIT OPEN,percent) 1 > 1 (&gt;L:XMLSND64,enum) } els{0}


<Value> (A:EXIT OPEN,percent) 1 &gt;
if{ (A:EXIT OPEN, Percent) 1 != if{
2 (&gt;L:XMLSND64,enum) } }
els{ (A:EXIT OPEN, Percent) 0 != if{
3 (&gt;L:XMLSND64,enum) } }
</Value>

I have tried COUNTLESS combinations, simple strings, and the above complex type versions.... This should be a super easy thing to do.... ?!

This doesnt even yet include the 'main power on' condition, only door open condition.

Anyone know what I am doing wrong or a basic quick way to write 'if door is open, power is on, make a goofy ding ding ding sound'?


Bill with gray, gigantic, brittle eyebrows..
 
It just occurred to me to check the sound file to make sure it works in FS, as some for some reason will not. Works fine.

Back to drudging along.
 
It just occurred to me to check the sound file to make sure it works in FS, as some for some reason will not. Works fine.

Back to drudging along.

If you're using DirectSound (as both Bill's gauge and mine do) then you're stuck with plain vanilla PCM file format. Fancy stuff, like ADPCM or MP3, will not work.

Doug
 
Hey Doug,

Roger that and yep, I tested it and its a standard Windows format 16bit WAV, so it does work in FS.



I just got it to sound off! But, it works with the door open and closed. Here is the code so far.



<Gauge Name="Door Alarm" Version="1.1">
<Size X="5" Y="5" />
<Element>
<Select>
<Value>
<!-- (A:EXIT OPEN, percent) 10 &gt; -->

(A:ELECTRICAL MASTER BATTERY,bool)

if{ (A:EXIT OPEN, Percent) 70 != if{
2 (&gt;L:XMLSND64,enum) } }

els{ (A:EXIT OPEN, Percent) 0 != if{
3 (&gt;L:XMLSND64,enum) } }
</Value>
</Select>
</Element>
</Gauge>


I have been playing with the percentage settings, trying to get that to settle it from running when the doors are closed, but nothing is working. If I take out the != and replace with &gt; and &lt; then the sound system goes dead again, with or without the doors being open.

Several hours on this. How embarrassing...
 
Are you monitoring the (A:EXIT OPEN, percent) variable during door operation to verify it is working as you think? I ask because that variable can be indexed when there are multiple exits, ie (A:EXIT OPEN:1, percent). Maybe your code is monitoring the incorrect door?
 
Are you monitoring the (A:EXIT OPEN, percent) variable during door operation to verify it is working as you think? I ask because that variable can be indexed when there are multiple exits, ie (A:EXIT OPEN:1, percent). Maybe your code is monitoring the incorrect door?



ACK! I didnt know to put in the door number... Must be same as the engines notations.

Thanks Daniel. I'll check that right now.



Bill
 
Bill,

A few thoughts...
Code:
(A:ELECTRICAL MASTER BATTERY,bool)
if{ 
(A:EXIT OPEN, Percent) 70 != 
	if{
	2 (&gt;L:XMLSND64,enum) 
	}
}
els{
(A:EXIT OPEN, Percent) 0 != 
	if{
	3 (&gt;L:XMLSND64,enum)
	}
}

The first thing your code does is evaluate the Master Battery variable. If the battery is on, we're into the 'if' block, where we are checking Exit Open against 70%.
If the battery is off, we're into the 'else' block, checking Exit Open against 0.
Not what you really wanted, I am sure.
I think what you are looking for is more along the lines of:
Code:
(A:ELECTRICAL MASTER BATTERY,bool)
if{ 
(A:EXIT OPEN, Percent) 70 != 
	if{
	2 (&gt;L:XMLSND64,enum) 
	}
	els{
	(A:EXIT OPEN, Percent) 0 != 
		if{
		3 (&gt;L:XMLSND64,enum)
		}
	}
}

I would suggest that you never, ever, put more than one brace bracket on a given line of code, and that each brace go on a line by itself.
Also, as soon as you type an opening {, type the closing } (on the next line.) Doing so will help you stay in scope as you complete the code.
Use tabs to match up if{ and els{ statements.
If the code is easier to read, it is easier to debug.

Another thing to keep in mind. Your comparison
(A:EXIT OPEN, Percent) 70 !=
is going to prove troublesome. You are comparing a floating point variable value against a fixed, integer value. In practice, this comparison will always return TRUE. The only time it will be false is when the Exit value is exactly 70%. If on one gauge update, the Exit value is 69.9995%, and on the next update, it is 70.0005%, we will have missed the test.
The only time it is safe to test using = or != is when you are testing against 0 or 100%. For anything else, you must use &gt; or &lt;.

Hope some of that is useful!

Doug
 
Many thanks Doug. That helps out tremendously in understanding this.


I think I must be on code variation 300. I have been at it all day. This is the latest one. It runs no matter what, doors open and closed.



Code:
       <Value> 
               (A:ELECTRICAL MASTER BATTERY,bool)
                if{ (A:EXIT OPEN:1,percent) 1 &gt;
               1 (&gt;L:XMLSND64,enum) }
                els{ (A:EXIT OPEN:1,percent) 0 
                3 (&gt;L:XMLSND64,enum) }
       </Value>

Oddly, it continuously loads the sound, and the sound level on the computer is really high. I have to cut it quickly to keep the sound level from hurting the speakers.
 
Code:
<Value> 
(A:ELECTRICAL MASTER BATTERY,bool)
    if{ (A:EXIT OPEN:1,percent) 1 &gt;
        if{ 1 (&gt;L:XMLSND64,enum) }
        els{ 3 (&gt;L:XMLSND64,enum) }
    }
    els{ 3 (&gt;L:XMLSND64,enum) }
</Value>

Try that....let me break it down. I haven't used the Doug's sound gauge in a while, but I am assuming 1 turns the sound on and 3 turns it off.

First, check if battery is on:

If battery is on:
Check if EXIT OPEN percent is greater than 1:
If it is: turn sound on.
Else it is NOT: turn sound off...notice no need to check is EXIT OPEN is equal to zero, because we already know it is NOT greater than 1, this will give you small buffer.

Else battery is NOT on:
Turn sound off.
 
Thanks for the try Daniel. Unfortunately that didnt work yesterday evening.

What it does is comes on, and continuously turns on the sound for some reason, escalating the dings to what sounds like 50 sounds overlapping. That is with the door open or closed, like its locked in the on switch sequence and continues turning on.

Man, a day to just get one code working, and not getting it working, lol... I 'must' learn about if/els statements/script writing. I need to know this.



Bill
 
Oh Sweet Jesus! :eek:

The sound flags are:
Code:
1 = play once
2 = start loop
3 = stop loop

You need to set a flag variable when the sound loop starts to prevent re-triggering it constantly. You need to have the opposite check to stop the sound loop, and finally you need to "kill the sound" when the battery switch is turned off and the doors remain open.

One Door:
Code:
<Value>
  (A:ELECTRICAL MASTER BATTERY,bool)
  if{ 
    (A:EXIT OPEN:1,percent) 1 &gt;
    (L:DoorDing,bool) 0 ==
    and
    if{  
      2 (&gt;L:XMLSND64,enum) 
      1 (&gt;L:DoorDing,bool)
  }
  (A:EXIT OPEN:1,percent) 0 ==
  (L:DoorDing,bool) 1 ==
  and
  if{ 
    3 (&gt;L:XMLSND64,enum)
    0 (&gt;L:DoorDing,bool)
    }
  }
  els{ 3 (&gt;L:XMLSND64,enum) }
</Value>
If you have two (or more) doors you want to annunciate, then you need to simply *OR* them in the start loop, and *AND* them in the stop section.


Two Doors:
Code:
<Value>
  (A:ELECTRICAL MASTER BATTERY,bool)
  if{ 
    (A:EXIT OPEN:1,percent) 1 &gt;
    (A:EXIT OPEN:2,percent) 1 &gt;
    or
    (L:DoorDing,bool) 0 ==
    and
    if{  
      2 (&gt;L:XMLSND64,enum) 
      1 (&gt;L:DoorDing,bool)
  }
  (A:EXIT OPEN:1,percent) 0 ==
  (A:EXIT OPEN:2,percent) 0 ==
  and
  (L:DoorDing,bool) 1 ==
  and
  if{
  3 (&gt;L:XMLSND64,enum)
    0 (&gt;L:DoorDing,bool)
    }
  }
  els{ 3 (&gt;L:XMLSND64,enum) }
</Value>
 
Last edited:
Hey Bill,

Some nicely written code, and many thanks for helping, but both of those do not work.


I wonder if this is a aircraft config thing? What a mystery. I used Shift/E to open the doors, both open, (EXIT OPEN:1) and it 'should' work. The sound file is good as I rigged SND64 to something else yesterday to check it in FS, and it worked fine. Doors are opening via Shift/E/1, but no sound. Electrics are all on.


Woot in the world....
 
I just tried swapping out sound circuits with SND63 and SND62, and those didnt work either. I had found, in the past, a dead circuit, but this doesnt seem to be the case.


Bill
 
It is working now! Dang, its nice... :D :D :D


Daniel, thank you Sir. It was your code block. It was missing == behind the 100;

Thanks FOJ for the heads up on the == missing.

Thanks Bill for trying for me.

Thanks everyone for your awesome patience.



Code, working;


<Gauge Name="Door Alarm" Version="1.1">
<Size X="5" Y="5" />
<Element>
<Select>

<Value>
(A:EXIT OPEN,percent) 100 ==
if{ (EXIT OPEN,percent) 100 ==
2 (&gt;L:XMLSND64,enum) }
els{ (EXIT OPEN,percent) 0 ==
3 (&gt;L:XMLSND64,enum) }
</Value>


</Select>
</Element>
</Gauge>



My thoughts were that == was only for enum operations. I didnt know it was required with this, a 100 percent statement.


Thanks again guys.


Bill O
 
Back
Top