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

FS2004 [SOLVED] Conditionals Limited to Two Variables?

Messages
232
Country
us-kentucky
While digging deep into my 747 electrical system, I have stumbled into an interesting problem.

I am trying to program the following bit of the electrical system: AC Bus 4 can be powered either by Generator 4, or by Generator 3 if Bus Tie Breakers 3 and 4 are closed.

Here is my code:

XML:
    <!-- AC Bus 4 -->
    <Element>
        <Select>
            <Value>
            (L:Gen 4 Powered, bool) 1 ==
            if{ 1 (>L:AC Bus 4 Powered, bool) }
            (L:Gen 3 Powered, bool) 1 == (L:BTB 3 Closed, bool) 1 ==  (L:BTB 4 Closed, bool) 1 == &amp;&amp;&amp;
            if{ 1 (>L:AC Bus 4 Powered, bool) }
            els{ 0 (>L:AC Bus 4 Powered, bool) }
            </Value>
        </Select>
    </Element>

For whatever reason, this code is powering AC Bus 4 with whatever the final variable of the longest line is. In the example above, closing Bus Tie Breaker 4 will cause AC Bus 4 to be powered, even if no generator is online!

If I take out one of the L vars in that line, the code will function as written, i.e. if I write this:

XML:
(L:Gen 3 Powered, bool) 1 == (L:BTB 3 Closed, bool) 1 == &amp;&amp;

Then AC Bus 4 will only be powered when Gen 3 is online and BTB 3 is closed.

What's going on here?
 
Messages
1,564
Country
thailand
There isn't a &amp;&amp;&amp; operator. &amp;&amp; is logical AND. &amp; is bitwise AND. You want two logical AND operators, so, using and instead of &amp;&amp; you could try

(L:Gen 3 Powered, bool) 1 == (L:BTB 3 Closed, bool) 1 == and (L:BTB 4 Closed, bool) 1 == and

or

(L:Gen 3 Powered, bool) 1 == (L:BTB 3 Closed, bool) 1 == (L:BTB 4 Closed, bool) 1 == and and

Bob
 
Messages
232
Country
us-kentucky
There isn't a &amp;&amp;&amp; operator. &amp;&amp; is logical AND. &amp; is bitwise AND. You want two logical AND operators, so, using and instead of &amp;&amp; you could try

(L:Gen 3 Powered, bool) 1 == (L:BTB 3 Closed, bool) 1 == and (L:BTB 4 Closed, bool) 1 == and

or

(L:Gen 3 Powered, bool) 1 == (L:BTB 3 Closed, bool) 1 == (L:BTB 4 Closed, bool) 1 == and and

Bob

Such a simple solution! I love this forum!

Thank you! It works perfectly now!
 
Top