• 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 2D gauge, 3 position switch template

Messages
10,088
Country
us-arizona
Hey all,

Does anyone have by chance a 3 position 2D switch code, or might know of one in a stock aircraft (XML) in FSX/P3D?

Just needs to be a switch with 3 cases or position/bitmaps, off, up, down.

Many thanks for any advice.


Bill
 

Zeiten

Resource contributor
Messages
444
Country
norway
Check out the default Beech Baron.

Remove case 3 & 4..

Code:
<Gauge Name="Right Ignition Switch" Version="1.0">
    <Element>
        <Select>
            <Value>(A:Old eng2 starter,enum)</Value>
            <Case Value="0">
                <Image Name="Ignition_Right_Off.bmp" />
            </Case>
            <Case Value="1">
                <Image Name="Ignition_Right_R.bmp" />
            </Case>
            <Case Value="2">
                <Image Name="Ignition_Right_L.bmp" />
            </Case>
            <Case Value="3">
                <Image Name="Ignition_Right_Both.bmp" />
            </Case>
            <Case Value="4">
                <Image Name="Ignition_Right_Start.bmp" />
            </Case>
        </Select>
    </Element>
    <Mouse>
        <Help ID="HELPID_GAUGE_MAGNETO_SWITCH" />
        <Area Right="19">
            <Cursor Type="DownArrow" />
            <Click Event="MAGNETO2_DECR" />
        </Area>
        <Area Left="19">
            <Cursor Type="UpArrow" />
            <Click Event="MAGNETO2_INCR" />
        </Area>
    </Mouse>
</Gauge>
 
Messages
10,088
Country
us-arizona
Cracks me up. I have grown knowledgeable on making parts animate in models via the ModelDef, but I have just discovered I know hardly anything about 2D gauges.

This needs to be an L:var with an enum system (I think). sigh...


This is what I have, but its not functioning.

Code:
<Gauge Name="FuelPanel_Toggle_Fuel_Transfer" Version="1.0">

    <Element>
        <Select>
            <Value>(L:LEARJET FILL TRANSFER SW,enum) 25 == </Value>
            <Case Value="0">
                <Image Name="Lear24BToggleOff.bmp" />
            </Case>
        </Select>
    </Element>

    <Element>
        <Select>
            <Value>(L:LEARJET FILL TRANSFER SW,enum) 0 == </Value>
            <Case Value="1">
                <Image Name="Lear24BToggleMid.bmp" />
            </Case>
        </Select>
    </Element>

    <Element>
        <Select>
            <Value>(L:LEARJET FILL TRANSFER SW,enum) 50 == </Value>
            <Case Value="2">
                <Image Name="Lear24BToggleOn.bmp" />
            </Case>
        </Select>
    </Element>


    <Mouse>

<Area Left="0" Width="51" Top="91" Height="90">
       <Tooltip>Fuel Transfer Toggle Switch</Tooltip>
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
                (L:LEARJET FILL TRANSFER SW,enum) 0 &gt; if{ (L:LEARJET FILL TRANSFER SW,enum) -- (&gt;L:LEARJET FILL TRANSFER

SW,enum) }
            </Click>
   </Area>

  <Area Left="0" Width="51" Top="0" Height="90">
       <Tooltip>Fuel Transfer Toggle Switch</Tooltip>
          <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
               (L:LEARJET FILL TRANSFER SW,enum) 3 &lt; if{ (L:LEARJET FILL TRANSFER SW,enum) ++ (&gt;L:LEARJET FILL TRANSFER

SW,enum) }
            </Click>
  </Area>

    </Mouse>

</Gauge>

And here is its counterpart 3D object animation code from the ModelDef which functions perfect;

Code:
<!--learjet24_fill_transfer-->


<PartInfo>
        <Name>learjet24_fill_transfer</Name>
        <AnimLength>50</AnimLength>
  <Animation>
  <Parameter>
       <Code>
          (L:LEARJET FILL TRANSFER SW,number)
       </Code>
     <Lag>950</Lag>
  </Parameter>
  </Animation>
  <MouseRect>
  <Cursor>Hand</Cursor>
  <TooltipText>Transfer Fill Selector Switch</TooltipText>
  <MouseFlags>LeftSingle+LeftDrag+Wheel</MouseFlags>
  <CallbackCode>
     (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:FILL MPos, number)         
         }
     (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:FILL MPos,number) - 20 + 0 &lt;
          if{
            (L:LEARJET FILL TRANSFER SW,number) 25 + (&gt;L:LEARJET FILL TRANSFER SW,number)
        (M:Y) (&gt;L:FILL MPos,number)
            (L:LEARJET FILL TRANSFER SW,number) 50 &gt;
             if{
               50 (&gt;L:LEARJET FILL TRANSFER SW,number)
               }
            els{
               1 (&gt;L:XMLSND1,enum)  
               }
        }
  (M:Y) (L:FILL MPos,number) - 20 - 0 &gt;
  if{
   (L:LEARJET FILL TRANSFER SW,number) 25 - (&gt;L:LEARJET FILL TRANSFER SW,number)
   (M:Y) (&gt;L:FILL MPos,number)
   (L:LEARJET FILL TRANSFER SW,number) 0 &lt;
   if{
    0 (&gt;L:LEARJET FILL TRANSFER SW,number)
   }
   els{
    1 (&gt;L:XMLSND1,enum)  
   }
  }
}
    (M:Event) 'WheelUp' scmp 0 ==
     if{
       (L:LEARJET FILL TRANSFER SW,number) 25 + (&gt;L:LEARJET FILL TRANSFER SW,number)
       (L:LEARJET FILL TRANSFER SW,number) 50 &gt;
       if{
         50 (&gt;L:LEARJET FILL TRANSFER SW,number)
         }
      els{
         1 (&gt;L:XMLSND12,enum)  
         }
       }
    (M:Event) 'WheelDown' scmp 0 ==
     if{
       (L:LEARJET FILL TRANSFER SW,number) 25 - (&gt;L:LEARJET FILL TRANSFER SW,number)
       (L:LEARJET FILL TRANSFER SW,number) 0 &lt;
        if{
          0 (&gt;L:LEARJET FILL TRANSFER SW,number)
          }
       els{
          1 (&gt;L:XMLSND1,enum)  
          }
       }        
</CallbackCode>
</MouseRect>
</PartInfo>
 
Messages
10,088
Country
us-arizona
I need this to command a 25 point 'step' or animation jump, 2X, in both directions, so that I click it 2 times and it goes from 0 to 1 to 2, or 0, 25, 50, and then vice versa.
 
Messages
440
Country
us-wisconsin
Bill,

This "may" get you going, mileage may vary. :rotfl:

Edit - I am assuming 0 = left/down position, 25 = mid position, 50 = right/up position?
Edit again - Click code
Edit again - Bitmap names

Code:
<Gauge Name="FuelPanel_Toggle_Fuel_Transfer" Version="1.0">
    <Element>
        <Select>
            <Value>(L:LEARJET FILL TRANSFER SW,enum)</Value>
            <Case Value="0">
                <Image Name="Lear24BToggleOff.bmp" />
            </Case>
            <Case Value="25">
                <Image Name="Lear24BToggleMid.bmp" />
            </Case>
            <Case Value="50">
                <Image Name="Lear24BToggleOn.bmp" />
            </Case>
        </Select>
    </Element>


<Mouse>
<Area Left="0" Width="51" Top="91" Height="90">
       <Tooltip>Fuel Transfer Toggle Switch</Tooltip>
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
                (L:LEARJET FILL TRANSFER SW,enum) 25 == if{ 0 (&gt;L:LEARJET FILL TRANSFER SW,enum) }
                (L:LEARJET FILL TRANSFER SW,enum) 50 == if{ 25 (&gt;L:LEARJET FILL TRANSFER SW,enum) }
            </Click>
</Area>
<Area Left="0" Width="51" Top="0" Height="90">
       <Tooltip>Fuel Transfer Toggle Switch</Tooltip>
          <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
                (L:LEARJET FILL TRANSFER SW,enum) 25 == if{ 50 (&gt;L:LEARJET FILL TRANSFER SW,enum) }
                (L:LEARJET FILL TRANSFER SW,enum) 0 == if{ 25 (&gt;L:LEARJET FILL TRANSFER SW,enum) }         
            </Click>
</Area>
</Mouse>
</Gauge>
 
Last edited:
Messages
10,088
Country
us-arizona
Cool. Many thanks Roman, off to check this out.

Yes to your question, but a couple of my switches will start in the middle. I guess I can easily control that via the graphics and syncing them with the 3D model parts which will be in their neutral 25 KF points.
 
Messages
440
Country
us-wisconsin
Just did a couple of edits above.. Taking care of the 25KF middle position. Hopefully.

Another way to do the click sections - Not to get things too complicated. :stirthepo

Code:
<Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
                (L:LEARJET FILL TRANSFER SW,enum) 25 - 0 max (&gt;L:LEARJET FILL TRANSFER SW,enum) } 
            </Click>

Code:
<Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
                (L:LEARJET FILL TRANSFER SW,enum) 25 + 50 min (&gt;L:LEARJET FILL TRANSFER SW,enum) } 
            </Click>
 
Messages
10,088
Country
us-arizona
10,000 Thanks Roman. That update did the trick. Working fine now.

I really need to learn or come to grips with how this enum system works.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Bill, "enum system" is nothing more complicated than 4th grade arithmetic, seriously. Don't allow the "enum" which is simply another way to write "number" to make it seem complicated... :cool:
 
Messages
2,077
Country
us-ohio
Technically enum is not 'simply another way to write "number"'... except in Microsoft's XML insanity.
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
It is true that FS XML's enum has nothing to do with other enum structures like those available in C/C++.

As a general rule, enum and number means exactly the same when used in FS XML scripts.

Tom
 

mgh

Messages
1,413
Country
unitedkingdom
If you have to ask... then you don't grasp the subtle difference.

That's why I did ask because I don't grasp the subtle difference.

According to the FSX SDK

ITrafficInfo Filter enum Yes One or more of the following values combined:

TRAFFIC_FILTER_AIRCRAFT = 1,
TRAFFIC_FILTER_GROUND_VEHICLES = 2,
TRAFFIC_FILTER_TOWER_CONTROLLERS = 4,
TRAFFIC_FILTER_ON_GROUND = 8,
TRAFFIC_FILTER_IN_AIR = 16,
TRAFFIC_FILTER_SLEEPING = 32,
TRAFFIC_FILTER_AWAKE = 64

Can the variable TRAFFIC_FILTER_AIRCRAFT be used in a XML gauge or not?
 
Messages
2,077
Country
us-ohio
You asked the wrong question... which indicates a desire to fight. No thanks.
 

mgh

Messages
1,413
Country
unitedkingdom
May be someone else will be able to answer the question?

You are the only one desiring to fight.
 
Messages
2,077
Country
us-ohio
Define an enum... based on the programming language... which XML is not one. Then consider that in an XML-defined gauge the term 'enum' means absolutely nothing.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Technically enum is not 'simply another way to write "number"'... except in Microsoft's XML insanity.
Well of course that's true. But then this entire discussion is taking place within the context of "Microsoft's XML insanity" isn't it?

Within the scope of this discussion there is no practical difference between "enum" and "number" as long as both are evaluated as whole numbers.

*Nota bene: The definition and usage of "enum" is different depending on context. It means something entirely different in each instance. Use in MySQL is not the same as C# for example.
https://www.google.com/#q=enum+versus+number
 
Last edited:
Top