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

FSX Radio xml Code Help

Messages
292
Country
unitedkingdom
I am new to xml gauge coding & have managed to successfully code the 19 gauges I have created for my panel so far, but need some help coding a radio, the comm-2 has a single digital display & I would like to be able to toggle between com2 active & com2 stby display, here is the code I have come up with so far for comm-2.
Code:
    <Element id="Comm-2 Active">
            <FloatPosition>55.000,197.000</FloatPosition>
            <Visibility>(A:CIRCUIT GENERAL PANEL ON, bool)</Visibility>
            <GaugeText id="GaugeText">
                <Bright>True</Bright>
                <FontColor>Orange</FontColor>
                <FontHeight>16</FontHeight>
                <GaugeString>%((A:Com active frequency:2,Megahertz))%!6.3f!</GaugeString>
                <HorizontalAlign>CENTER</HorizontalAlign>
                <Size>56,20</Size>
                <Transparent>True</Transparent>
            </GaugeText>
        </Element>
        <Element id="Comm-2 Stby">
            <FloatPosition>55.000,197.000</FloatPosition>
            <Visibility>(A:CIRCUIT GENERAL PANEL ON, bool)</Visibility>
            <GaugeText id="GaugeText">
                <Bright>True</Bright>
                <FontColor>Orange</FontColor>
                <FontHeight>16</FontHeight>
                <GaugeString>%((A:Com standby frequency:2,Megahertz))%!6.3f!</GaugeString>
                <HorizontalAlign>CENTER</HorizontalAlign>
                <Size>56,20</Size>
                <Transparent>True</Transparent>
            </GaugeText>
        </Element>
            <MouseArea id="Comm-2 Adj Whole">
                <FloatPosition>56.000,242.000</FloatPosition>
                <Size>28,84</Size>
                <MouseArea id="Decrement">
                    <FloatPosition>0.000,0.000</FloatPosition>
                    <Size>28,28</Size>
                    <CursorType>DownArrow</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>   1 (&gt;K:COM2_RADIO_WHOLE_DEC)</Script>
                        <ClickRepeat>True</ClickRepeat>
                    </MouseClick>
                </MouseArea>
                <MouseArea id="Increment">
                    <FloatPosition>0.000,28.000</FloatPosition>
                    <Size>28,56</Size>
                    <CursorType>UpArrow</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>           1 (&gt;K:COM2_RADIO_WHOLE_INC)</Script>
                        <ClickRepeat>True</ClickRepeat>
                    </MouseClick>
                </MouseArea>
            </MouseArea>
            <MouseArea id="Comm-2 Frac">
                <FloatPosition>84.000,242.000</FloatPosition>
                <Size>28,56</Size>
                <MouseArea id="Decrement">
                    <FloatPosition>0.000,0.000</FloatPosition>
                    <Size>28,28</Size>
                    <CursorType>DownArrow</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>  1 (&gt;K:COM2_RADIO_FRACT_DEC)</Script>
                        <ClickRepeat>True</ClickRepeat>
                    </MouseClick>
                </MouseArea>
                <MouseArea id="Increment">
                    <FloatPosition>0.000,28.000</FloatPosition>
                    <Size>28,28</Size>
                    <CursorType>UpArrow</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>  1 (&gt;K:COM2_RADIO_FRACT_INC)</Script>
                        <ClickRepeat>True</ClickRepeat>
                    </MouseClick>
                </MouseArea>
            </MouseArea>
            <MouseArea id="Comm-2 Swap">
                <FloatPosition>140.000,190.000</FloatPosition>
                <Size>30,30</Size>
                <CursorType>Hand</CursorType>
                <MouseArea id="MouseArea">
                    <FloatPosition>0.000,0.000</FloatPosition>
                    <Size>30,30</Size>
                    <CursorType>Hand</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>1 (&gt;K:COM2_STBY_RADIO_SWAP)</Script>
                    </MouseClick>
                </MouseArea>
            </MouseArea>

I am assuming that a visibilty script is required in the Comm-2 Active element, but can't seem to be able come up with anything.

Any help & advice would be much appreciated.
 
Hey Paul,

When you have this display, only the standby is 'clickable'. The active will have no effect on clicking it. I am sure you know that though.

If you mean that you need both displays to show up in 'one' display window, then yes, you do need a 'visibility'. Just note that you might wish to make the click zones (mouse rects) to turn off (with a mouse visibility) also to keep from messing up your setting on the radio freqs.

You can do a terribly easy on/off visibility system for it, and have a button that turns them on and off.

Note, you will need to make the visibility button separate from the clickzone for the freq adjustment. No overlaying of clickzones can occur.

Button for going between 'Active' and 'Standby' could be something like;


Code:
            <MouseArea id="COM2 ACTIVE STANDBY SWITCH">
                <FloatPosition>140.000,190.000</FloatPosition>
                <Size>30,30</Size>
                <CursorType>Hand</CursorType>
                <MouseArea id="MouseArea">
                    <FloatPosition>0.000,0.000</FloatPosition>
                    <Size>30,30</Size>
                    <CursorType>Hand</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>(L:Standby Switchover,bool) ! (>L:Standby Switchover,bool)</Script>
                    </MouseClick>
                </MouseArea>


Then on each code, you insert a 'visibility' string section and have on one (L:Standby Switchover,bool) 1 == as your 'on' (clicked on, otherwise its sleeping), and the second that is (L:Standby Switchover,bool) ! (off) as your primary where that is how it will boot up as, normal view.

Example for one with a visibility string in FS2004 XML (I do not have FSX XML), would be;

Code:
   <Area Left="50" Top="30" Right="170" Bottom="155">
     <Visible> (L:Standby Switchover,bool) ! </Visible>
        <Tooltip>GPS Page</Tooltip>
         <Cursor Type="Hand"/>
        <Click Kind="LeftSingle">
                  2 (&gt;L:List_CascadeB,enum)
                  1 (&gt;L:XMLSND60,enum)
        </Click>
      </Area>

Mind you, the above block of code is in FS2004 XML, not FSX XML, so change that over. This is to hide the mouse command area from being clicked by mistake when Active is visible. With Active, you want visibility on (1 ==).

<Visible> (L:Standby Switchover,bool) 1 == </Visible> <-- FS2004 string. might be different in FSX XML.


You would do the same for your code blocks, putting in a visibility insert string in them so that one shows up with 1 == and one shows up with !

Hope that helps.


Bill
 
Paul,

It's awkward for a radio to be able to display only one frequency but also have Active and Standby capability. However, if that is your case, then give this a try and see if you get the result you want:

Display and tune only the Active, then use >K:COM2_STBY_RADIO_SWAP to swap active and standby. You won't need a Visible flag, nor will you need an Element to display A:COM STANDBY FREQUENCY:2.

Also, edit your aircraft.cfg file so that when you tune the radio, it tunes the active, not the standby:

[Radios]
// Radio Type=available, standby frequency, has glide slope
Com.1=1, 1
Com.2=1, 0

I think this will work for you ...

Bob
 
Thanks Bill,

I have got the com2 active & stby displays to toggle using " (L:Standby Switchover,bool) ! " & "(L:Standby Switchover,bool) 1 == " for the display visibilty, but I need to be able to swap the frequences, is it possible to include a "COM_STBY_RADIO_SWAP" in the mouse area script for the "active-stby click point" along with the "(L:Standby Switchover,bool) ! (&gt;L:Standby Switchover,bool)" code, here's a pic of the comm 2.

Comm 2.png


I have enabled the green led to to show only when active frequency is selected so when off the stby frequency can be changed, I used the same visibilty code as the com2 active display.

Bob, thank you for your response, I don't quite understand how to go about coding your suggestion.

Thanks again for the help.

Paul
 
What would be cool is if you did 'mouse click' to turn on Standby, then use 'mouse wheel' to adjust the freq, and have a timer run the standby visibility. Then it would auto-hide and revert to regular 'active' view mode.

You would have click zone types with left click, wheel up, and wheel down. You would need a timer code for the visibility of the standby and active, like when its active, standby is 1 and active is 0, then revert it back when timer is finished. Have the timer restart each time you left click the knob so that you always have so much time to see it and change it. Then after like 3 or 5 seconds or what ever you wish, it changes back to active.

That would be pretty cool, but I do not know if thats what the original radio does. Mine might be the wrong way to go.

You would need your M zones to be properly coded and setup your mouse click type strings.

I do not know (right now) how you would do the timer. I am in the middle of re-launching a plane, so kind of tied up, presently. Here is an example of M zones;


Note, these are just to show you how M:Events work. You would then install your own code for what you are doing. This was some semi exotic code for a multi position switch. Just ignore my own coding. Just want to show you the types of mouse events you can put into a single switch.

This would be a left click M:Event
(M:Event) 'LeftSingle' scmp 0 ==
if{
(M:Y) (&gt;L:LEFT_LANLITE_SELECT_MPos, number)
}


// this would be a mouse wheel M:Event
(M:Event) 'WheelUp' scmp 0 ==
if{
(L:RIGHT_LANLITE_SELECT_POS,number) 25 + (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
(L:RIGHT_LANLITE_SELECT_POS,number) 50 &gt;
if{
50 (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
}
els{
1 (&gt;L:XMLSND1,enum)
}
}

(M:Event) 'WheelDown' scmp 0 ==
if{
(L:RIGHT_LANLITE_SELECT_POS,number) 25 - (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
(L:RIGHT_LANLITE_SELECT_POS,number) 0 &lt;
if{
0 (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
}
els{
1 (&gt;L:XMLSND1,enum)
}
}
 
is it possible to include a "COM_STBY_RADIO_SWAP" in the mouse area script for the "active-stby click point" along with the "(L:Standby Switchover,bool) ! (&gt;L:Standby Switchover,bool)" code


Yes, but for it to work correctly, your mouse click script should look something like this:

XML:
<Area Name="ACTIVE-STBY CLICK POINT" Left="5" Top="5" Width="20" Height="20">
    <Cursor Type="Hand"/>
    <Click Kind="LeftSingle">
        (L:Standby Switchover, bool) ! (>L:Standby Switchover, bool)
        (L:Standby Switchover, bool) 0 == if{ (>K:COM2_RADIO_SWAP) }
    </Click>
</Area>

Change Left, Top, Width, Height to fit your situation.

Important Note: The XML script I pasted, above, is formatted using FS9 XML schema (which is compatible with FSX and P3D sims). Your XML appears to be the more verbose FSX schema. You can't mix the two formats within a single gauge, so just take my idea and put it into your mouse click code.

That is, you need to add (L:Standby Switchover, bool) 0 == if{ (>K:COM2_RADIO_SWAP) } after (L:Standby Switchover, bool) ! (>L:Standby Switchover, bool)

Bob
 
Last edited:
Bob,

Thank you so much, I have now got it working as I wanted :), I am using the "ace" tool so yes it is FSX schema & I have now learbt a little bit more about coding, but still have very much to learn.

Bill,

Thank you for your help & last post, but that looks rather complicated for me at the moment, but hopefully it will make more sense to me in the future.
 
No problem. I am learning as well. I try to help out when I can but am still quite a bit green at this.

Once you learn how basic logic works and how to write it, it gets much easier and you can do amazing things. Timers are brilliant. I am just learning (more) about those. So much you can do...
 
Back
Top