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

P3D v5 [Solved] Assign a variable to the initial page

Messages
4
Country
italy
Hi everyone!
I'm new in this forum and new to the development of gauges so I need an help. I'm making an EFB in XML (Code below) for a plane I'm modifying and I wanted to show a menu on the top left corner that changes depending on the page. I was able to get the first 2 pages with the menu working but I have no idea of what I could do to make the menu change. I was thinking about using a variable for each page that changes when switching trough pages for example when on the main page I use (L: Main_Page, bool) and when on the doors page I use (L: Door_Page, bool) and then I make a menu for every page using one of those variables for the visibility but how can I assign a variable to the page the EFB starts with which is Main_Page in this case?

Code:
<Gauge Name="EFB" Version="1.0">
    <Element Name="Main_Page">
        <Element>
            <Position X="0" Y="0"/>
            <Select>
                <Value>(A:ELECTRICAL MASTER BATTERY, bool)</Value>
                <Case Value="1">
                    <Image Name="EFB_MainPage.bmp" Luminous="True"/>
                </Case>
            </Select>
        </Element>
    </Element>
    <Element Name="Main_Menu">
        <Element>
            <Position X="0" Y="100"/>
            <Select>
                <Value>(L:Active_Menu, bool)</Value>
                <Case Value="1">
                    <Image Name="Doors.bmp" Luminous="True"/>
                </Case>
            </Select>
        </Element>
        <Element>
            <Position X="0" Y="200"/>
            <Select>
                <Value>(L:Active_Menu, bool)</Value>
                <Case Value="1">
                    <Image Name="Ground.bmp" Luminous="True"/>
                </Case>
            </Select>
        </Element>
    </Element>
    <Element Name="Doors_Page">
        <Element>
            <Position X="0" Y="0"/>
            <Select>
                <Value>(L:Door_Page, bool)</Value>
                <Case Value="1">
                    <Image Name="Doors_Page.bmp" Luminous="True"/>
                </Case>
            </Select>
        </Element>
  </Element>
    <Mouse Name="Menu">
        <Area Name="Menu" Left="0" Top="0" Width="263" Height="99">
            <Click>
                (L:Active_Menu, bool) ! (&gt;L:Active_Menu)
            </Click>
            <Cursor Type="Hand"/>
        </Area>
        <Area Name="DOORS" Left="0" Top="100" Width="263" Height="99">
            <Visible>(L:Active_Menu, bool)</Visible>
            <Click>
                (L:Door_Page, bool) ! (&gt;L:Door_Page, bool)
                0 (>L:Active_Menu, bool)
            </Click>
            <Cursor Type="Hand"/>
        </Area>
    </Mouse>
</Gauge>
 
Last edited:

tgibson

Resource contributor
Messages
11,338
Country
us-california
Rather than use a separate variable for each page, use a single variable and assign a value to each page (Page_Displayed, enum, for example). Set the Main Page to be displayed when the variable = 0, because by default this is the value of all L: variables when you load a plane. So when you load the plane, your code will display the main page (<Case Value="0">). Then display your other pages when the Case Value is 1, 2, 3, etc.

You can increment the Page_Displayed value in your mouse section by using something like (L:page_Displayed, enum) ++ (&gt;L:page_Displayed, enum). When you get to the last page (i.e. the maximum value of Page_Displayed has now been exceeded by one), sense this and reset the value to 0, to go back to the main page.

Or make it even fancier with a line across the top or bottom of each page with links to each of the other pages (i.e. set Page_Displayed to a specific value for each link).
 
Messages
4
Country
italy
Rather than use a separate variable for each page, use a single variable and assign a value to each page (Page_Displayed, enum, for example). Set the Main Page to be displayed when the variable = 0, because by default this is the value of all L: variables when you load a plane. So when you load the plane, your code will display the main page (<Case Value="0">). Then display your other pages when the Case Value is 1, 2, 3, etc.

You can increment the Page_Displayed value in your mouse section by using something like (L:page_Displayed, enum) ++ (&gt;L:page_Displayed, enum). When you get to the last page (i.e. the maximum value of Page_Displayed has now been exceeded by one), sense this and reset the value to 0, to go back to the main page.

Or make it even fancier with a line across the top or bottom of each page with links to each of the other pages (i.e. set Page_Displayed to a specific value for each link).
So, if I understand correctly let's say I have as you said (L: Page_Displayed, enum) as variable, I display the main page just by using <Case Value="0"> cause it is the initial value of the variable and that's okay but then if I want to add a click spot how can I make it show up just for the main page in particular? By using <Visibility>(L: Page_Displayed, enum) 0</Visibilty>? Changing then the 0 to 1 to 2 etc... depending on the number assigned to the page? Also instead of "(L: Page_Displayed, enum) ++ (&gt;L: Page_Displayed, enum)" can I use "(L: Page_Displayed, enum) ! (&gt;L: Page_Displayed, enum) 0 (1 or 2 depending from the page)"?
 
Last edited:
Messages
495
Country
austria
Do make it short.. for 5 pages defined

Code:
<!-- MOUSE *** APT Subpage select -->
  <Area Top="23" Bottom="30" Left="126" Right="155">
  <Tooltip> L: Prev Page  %n R: Next Page </Tooltip>
  <Cursor Type="Hand"/>
    <Click Kind="LeftSingle+RightSingle">
    (M:Event)
    'LeftSingle' scmp 0 ==
    if{
      (L:NavM_POST_Apt_Subpage,number) -- (&gt;L:NavM_POST_Apt_Subpage,number)
      (L:NavM_POST_Apt_Subpage,number) 1 &lt;
      if{
        5 (&gt;L:NavM_POST_Apt_Subpage,number)
        }
      }
    (M:Event)
    'RightSingle' scmp 0 ==
    if{
      (L:NavM_POST_Apt_Subpage,number) ++ (&gt;L:NavM_POST_Apt_Subpage,number)
      (L:NavM_POST_Apt_Subpage,number) 5 &gt;
      if{
        1 (&gt;L:NavM_POST_Apt_Subpage,number)
        }
      }
    </Click>
  </Area>
 
Messages
4
Country
italy
if{ (L:NavM_POST_Apt_Subpage,number) -- (&gt;L:NavM_POST_Apt_Subpage,number) (L:NavM_POST_Apt_Subpage,number) 1 &lt; if{ 5 (&gt;L:NavM_POST_Apt_Subpage,number) } }
As a complete newbie here, I have to ask. What does this part exactly do?
 
Last edited:
Messages
2,077
Country
us-ohio
It decrements the variable by 1 and assigns it to itself. If that makes it less than 1, it sets it to 5 (wraps around, value-wise).
 

tgibson

Resource contributor
Messages
11,338
Country
us-california
And yes, you can use Visible statements in Mouse sections to control them. An example:

XML:
<!-- set Fuel Load -->

      <Area Left="40" Right="210" Top="340" Bottom="360">
      <Visible> (A:GENERAL ENG1 COMBUSTION, bool) ! (A:GENERAL ENG2 COMBUSTION, bool) ! (A:GENERAL ENG3 COMBUSTION, bool) ! (A:GENERAL ENG4 COMBUSTION, bool) ! &amp;&amp; &amp;&amp; &amp;&amp; (A:SIM ON GROUND, bool) &amp;&amp; (A:BRAKE PARKING POSITION, bool) &amp;&amp; </Visible>
            <Tooltip>Click to add/subract fuel if current fuel (%((A:Fuel Total Quantity, gallons) @Fuel_Weight * )%!d!) above/below Total Fuel</Tooltip>
         <Cursor Type="Hand"/>
         <Click>(A:GENERAL ENG1 COMBUSTION, bool) ! (A:GENERAL ENG2 COMBUSTION, bool) ! (A:GENERAL ENG3 COMBUSTION, bool) ! (A:GENERAL ENG4 COMBUSTION, bool) ! &amp;&amp; &amp;&amp; &amp;&amp; (A:SIM ON GROUND, bool) &amp;&amp; (A:BRAKE PARKING POSITION, bool) &amp;&amp; if{ 1 (&gt;G:Var6) } </Click>
      </Area>
 
Top