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

XML Taxi\Gear Light Switch

Messages
39
Country
us-newhampshire
I'm trying to use some custom code for a VC taxi\light switch and make an external 2D switch.
The VC switch is 3 position down being off, mid being taxi and up for landing lights. I have a 2D taxi light switch but can't figure out the syntax for the landing lights. From what I can see in the mdl the var "gearlight mode" should work.

Here is the 2D taxi code:
<Element>
<Position X="70" Y="79"/>
<Select>
<Value>(L:GearLight Mode, ENUM)</Value>
<Case Value="1">
<Image Name="posky_sw_on.bmp"/>
</Case>
<Case Value="0">
<Image Name="posky_sw_off.bmp"/>
</Case>
</Select>
</Element>

<Area Left="70" Top="79" Width="32" Height="24">
<Tooltip>TAXI LIGHTS</Tooltip>
<Cursor Type="Hand"/>
<Click>(L:GearLight Mode, bool) ! (&gt;L:GearLight Mode, bool)</Click>
</Area>

Here are pics of the code in the mdl..?

Any help would be appreciated...
 

Attachments

  • text.jpg
    text.jpg
    42.3 KB · Views: 496
  • hex.jpg
    hex.jpg
    46.4 KB · Views: 473
This should work,

First make a middle switch position bitmap out of either posky_sw_on.bmp or posky_sw_off.bmp and call it "my_middle.bmp"

Then use the following code

Code:
<Element>
<Position X="70" Y="79"/>
<Select>
<Value>(L:GearLight Mode, ENUM)</Value>
<Case Value="0">
<Image Name="posky_sw_off.bmp"/>
</Case>
<Case Value="1">
<Image Name="my_middle.bmp"/>
</Case>
<Case Value="2">
<Image Name="posky_sw_on.bmp"/>
</Case>
</Select>
</Element>


<Area Left="70" Top="79" Width="32" Height="12">
<Tooltip>TAXI/LANDING  LIGHTS</Tooltip>
<Cursor Type="UpArrow"/>
<Click>(L:GearLight Mode, enum) ++ 2 min (&gt;L:GearLight Mode, enum)</Click>
</Area>

<Area Left="70" Top="93" Width="32" Height="12">
<Tooltip>TAXI/LANDING  LIGHTS</Tooltip>
<Cursor Type="DownArrow"/>
<Click>(L:GearLight Mode, enum) -- 0 max (&gt;L:GearLight Mode, enum)</Click>
</Area>
 
This should work,

First make a middle switch position bitmap out of either posky_sw_on.bmp or posky_sw_off.bmp and call it "my_middle.bmp"

Then use the following code

Code:
<Element>
<Position X="70" Y="79"/>
<Select>
<Value>(L:GearLight Mode, ENUM)</Value>
<Case Value="0">
<Image Name="posky_sw_off.bmp"/>
</Case>
<Case Value="1">
<Image Name="my_middle.bmp"/>
</Case>
<Case Value="2">
<Image Name="posky_sw_on.bmp"/>
</Case>
</Select>
</Element>


<Area Left="70" Top="79" Width="32" Height="12">
<Tooltip>TAXI/LANDING  LIGHTS</Tooltip>
<Cursor Type="UpArrow"/>
<Click>(L:GearLight Mode, enum) ++ 2 min (&gt;L:GearLight Mode, enum)</Click>
</Area>

<Area Left="70" Top="93" Width="32" Height="12">
<Tooltip>TAXI/LANDING  LIGHTS</Tooltip>
<Cursor Type="DownArrow"/>
<Click>(L:GearLight Mode, enum) -- 0 max (&gt;L:GearLight Mode, enum)</Click>
</Area>


Thanks very much, it works as I'd hoped for...!
I still can't follow the logic, but I can learn from it which is a big plus as well.
 
++ means to add 1 to the variable. 2 min means that the value cannot exceed 2.

-- means to subtract one. 0 max means that the value cannot go lower than 0.

Yes, the max and min seem to be opposite in meaning, but so is a lot of XML code. :)

Hope this helps,
 
++ means to add 1 to the variable. 2 min means that the value cannot exceed 2.

-- means to subtract one. 0 max means that the value cannot go lower than 0.

Yes, the max and min seem to be opposite in meaning, but so is a lot of XML code. :)

Hope this helps,


What I don't understand is how first the taxi light and then the twin landing lights turn separately..
 
I am confused too...

Nothing in spokes2112's code turns on any lights using the commands that I know and 'love' ( eg K:LANDING_LIGHTS_ON or K:TOGGLE_TAXI_LIGHTS). There must be code elsewhere which uses the LVAR GearLight Mode to do the trick.

Walter
 
The custom LVAR , "GearLight Mode" is used instead of the standard commands.
If "++" adds one to the variable, what would be the syntax for having two added to the variable...? Say for example you wanted two separate switches,
one for each set of lights.














=
 
First off you will not be able to have both operating simultaneously. The taxi and landing lights are coded into the model. 0 = off, 1 = taxi, 2 = landing. As for 2 separate switches you could do the following. (Of course X/Y coordinates would have to be changed)

Taxi light -
Code:
<Element>
<Position X="70" Y="79"/>
<Select>
<Value>(L:GearLight Mode, enum) 1 ==</Value>
<Case Value="0">
<Image Name="posky_sw_off.bmp"/>
</Case>
<Case Value="1">
<Image Name="posky_sw_on.bmp"/>
</Case>
</Select>
</Element>


<Area Left="70" Top="79" Width="32" Height="12">
<Tooltip>TAXI LIGHTS</Tooltip>
<Cursor Type="UpArrow"/>
<Click>1 (&gt;L:GearLight Mode, enum)</Click>
</Area>

<Area Left="70" Top="93" Width="32" Height="12">
<Tooltip>TAXI LIGHTS</Tooltip>
<Cursor Type="DownArrow"/>
<Click>(L:GearLight Mode, enum) 1 == if{ 0 (&gt;L:GearLight Mode, enum) }</Click>
</Area>

Landing Light -
Code:
<Element>
<Position X="70" Y="79"/>
<Select>
<Value>(L:GearLight Mode, enum) 2 ==</Value>
<Case Value="0">
<Image Name="posky_sw_off.bmp"/>
</Case>
<Case Value="1">
<Image Name="posky_sw_on.bmp"/>
</Case>
</Select>
</Element>


<Area Left="70" Top="79" Width="32" Height="12">
<Tooltip>LANDING LIGHTS</Tooltip>
<Cursor Type="UpArrow"/>
<Click>2 (&gt;L:GearLight Mode, enum)</Click>
</Area>

<Area Left="70" Top="93" Width="32" Height="12">
<Tooltip>LANDING LIGHTS</Tooltip>
<Cursor Type="DownArrow"/>
<Click>(L:GearLight Mode, enum) 2 == if{ 0 (&gt;L:GearLight Mode, enum) }</Click>
</Area>

EDIT - Additions are done as such (adding 10 to variable) -
Code:
(L:Variable, number) 10 + (&gt;L:Variable, number)
 
Last edited:
BTW, adding two to a variable:

Code:
(L:GearLight Mode, enum) 2 + (&gt;L:GearLight Mode, enum)
 
Thanks Tom.

I'm running into a situation where my external light switches work for one model of aircraft but not for another.
From what I can see the code syntax looks exactly the same but I believe the problem maybe a conditional parameter where the 2D panel needs to set the light bus power.
Please see below, does the code suggest that is true and how would the code be written..? OR I could be filled with hot air....


(L:Light Bus Power, number) 1 == if{ (L:Formation Light Switch, enum) ! (>L:Formation Light Switch, enum) } els{ 0 }
 
I had created mine, which works exactly like this, in the ModelDef, but needed a 2D switch for it and finally figured out a way to make it work, but its click zone oriented; middle is taxi, lower area is off, top is landing.

Note, this works with ModelDef and has a 'invisible lights management gauge' that reads the L:var's of these and turns on the lights needed. (Sounds complicated but its not). But at least you can see how the click code mouse area works. Fairly easy. Also, this controls left and right landing lights and taxi lights via 'visibilities' in the 3D model on the light polygons.

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

    <Element>
        <Select>
            <Value>(L:RIGHT_LANLITE_SELECT_POS,number)</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" Right="51" Top="-20" Bottom="50">
       <Tooltip>Landing Lights</Tooltip>
          <Cursor Type="Hand"/>
            <Click Repeat="Yes">
         50 (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
          1 (&gt;L:XMLSND1,enum) 
            </Click>
</Area>

      <Area Left="0" Right="51" Top="52" Bottom="130">
       <Tooltip>Taxi Lights</Tooltip>
          <Cursor Type="Hand"/>
            <Click Repeat="Yes">
         25 (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
          1 (&gt;L:XMLSND1,enum) 
            </Click>
</Area>

      <Area Left="0" Right="51" Top="131" Bottom="220">
       <Tooltip>Landing and Taxi Lights Off</Tooltip>
          <Cursor Type="Hand"/>
            <Click Repeat="Yes">
          0 (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
          1 (&gt;L:XMLSND1,enum) 
            </Click>

</Area>

</Mouse>

</Gauge>


Code:
<!-- Landing Lights Circuit Manager -->

<Element>
<Select>
<Value>
             (L:LJ24B BATT MASTER LEFT, bool) 1 ==
             (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
             and
               if{ (L:LEFT_LANLITE_SELECT_POS,number) 40 &gt;
                   (L:RIGHT_LANLITE_SELECT_POS,number) 40 &gt;
                   or
                     if{ (>K:LANDING_LIGHTS_ON) }
                    els{ (>K:LANDING_LIGHTS_OFF) }
                 }
  </Value>
</Select>
</Element>

<!-- Taxi Lights Circuit Manager -->

<Element>
<Select>
<Value>
             (L:LJ24B BATT MASTER LEFT, bool) 1 ==
             (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
             and
               if{ 20 30 (L:LEFT_LANLITE_SELECT_POS,number) rng
                   20 30 (L:RIGHT_LANLITE_SELECT_POS,number) rng
                   or
                     if{ (>K:TOGGLE_TAXI_LIGHTS) }
                 }
  </Value>
</Select>
</Element>

<!-- Left Landing Light -->

<Element>
<Select>
<Value>
             (L:LEFT_LANLITE_SELECT_POS,number) 40 &gt;
             (L:LJ24B BATT MASTER LEFT, bool) 1 ==
             (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
             and and
          if{ 1 (>L:learjet24 l lndg light viz,bool) }
         els{ 0 (>L:learjet24 l lndg light viz,bool) }
  </Value>
</Select>
</Element>

<!-- Right Landing Light -->

<Element>
<Select>
<Value>
             (L:RIGHT_LANLITE_SELECT_POS,number) 40 &gt;
             (L:LJ24B BATT MASTER LEFT, bool) 1 ==
             (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
             and and
          if{ 1 (>L:learjet24 r lndg light viz,bool) }
         els{ 0 (>L:learjet24 r lndg light viz,bool) }
  </Value>
</Select>
</Element>


<!-- Right Taxi Light -->

<Element>
<Select>
<Value>
       20 30 (L:RIGHT_LANLITE_SELECT_POS,number) rng
             (L:LJ24B BATT MASTER LEFT, bool) 1 ==
             (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
             and and
                if{ 1 (>L:learjet24 r taxi light viz) }
               els{ 0 (>L:learjet24 r taxi light viz) }
  </Value>
</Select>
</Element>

<!-- Left Taxi Light -->

<Element>
<Select>
<Value>
       20 30 (L:LEFT_LANLITE_SELECT_POS,number) rng
             (L:LJ24B BATT MASTER LEFT, bool) 1 ==
             (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
             and and
                if{ 1 (>L:learjet24 l taxi light viz,bool) }
               els{ 0 (>L:learjet24 l taxi light viz,bool) }
  </Value>
</Select>
</Element>
 
Thanks for the code, I can see what you've done as far as the mouse click areas.
I added the code but am not seeing any functioning lights. I think I need to work with the lights circuit manager code further.
 
Seahawk,

Hang on. Here is the 'visibilities' already written. Its like half of the code. Sorry I didnt include these. These will 'appear' when the proper switch is in the proper position. You make the landing and taxi polytons, get those working, then attach these visibilities to those; LH to LH, RH to RH.


Code:
<!--learjet24_l_lndg_light_viz-->

  <PartInfo>
    <Name>learjet24_l_lndg_light_viz</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:learjet24 l lndg light viz) 1 ==
          if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

<!--learjet24_l_taxi_light_viz-->

  <PartInfo>
    <Name>learjet24_l_taxi_light_viz</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:learjet24 l taxi light viz) 1 ==
          if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

<!--learjet24_r_lndg_light_viz-->

  <PartInfo>
    <Name>learjet24_r_lndg_light_viz</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:learjet24 r lndg light viz) 1 ==
          if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

<!--learjet24_r_taxi_light_viz-->

  <PartInfo>
    <Name>learjet24_r_taxi_light_viz</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:learjet24 r taxi light viz) 1 ==
          if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>



I am also sending these over. These are the two switches; LH and RH, and have the same code in them as the other parts. This is one of the most brilliant code blocks I have seen, a 3 position, off, taxi, l-light switch, that is 'drag-able'. I believe Anthony was the one that showed me how this is done.


Code:
<PartInfo>
      <Name>learjet24_landing_taxi_left</Name>
        <AnimLength>50</AnimLength>
  <Animation>
  <Parameter>
       <Code>
          (L:LEFT_LANLITE_SELECT_POS,number)
       </Code>
     <Lag>950</Lag>
  </Parameter>
  </Animation>
  <MouseRect>
  <Cursor>Hand</Cursor>
  <TooltipText>Left Landing and Taxi Light Switch</TooltipText>
  <MouseFlags>LeftSingle+LeftDrag+Wheel</MouseFlags>
  <CallbackCode>
     (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:LEFT_LANLITE_SELECT_MPos, number)         
         }
     (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:LEFT_LANLITE_SELECT_MPos,number) - 20 + 0 &lt;
          if{
            (L:LEFT_LANLITE_SELECT_POS,number) 25 + (&gt;L:LEFT_LANLITE_SELECT_POS,number)
        (M:Y) (&gt;L:LEFT_LANLITE_SELECT_MPos,number)
            (L:LEFT_LANLITE_SELECT_POS,number) 50 &gt;
             if{
               50 (&gt;L:LEFT_LANLITE_SELECT_POS,number)
               }
            els{
               1 (&gt;L:XMLSND1,enum)  
               }
        }
  (M:Y) (L:LEFT_LANLITE_SELECT_MPos,number) - 20 - 0 &gt;
  if{
   (L:LEFT_LANLITE_SELECT_POS,number) 25 - (&gt;L:LEFT_LANLITE_SELECT_POS,number)
   (M:Y) (&gt;L:LEFT_LANLITE_SELECT_MPos,number)
   (L:LEFT_LANLITE_SELECT_POS,number) 0 &lt;
   if{
    0 (&gt;L:LEFT_LANLITE_SELECT_POS,number)
   }
   els{
    1 (&gt;L:XMLSND1,enum)  
   }
  }
}
    (M:Event) 'WheelUp' scmp 0 ==
     if{
       (L:LEFT_LANLITE_SELECT_POS,number) 25 + (&gt;L:LEFT_LANLITE_SELECT_POS,number)
       (L:LEFT_LANLITE_SELECT_POS,number) 50 &gt;
       if{
         50 (&gt;L:LEFT_LANLITE_SELECT_POS,number)
         }
      els{
         1 (&gt;L:XMLSND1,enum)  
         }
       }
    (M:Event) 'WheelDown' scmp 0 ==
     if{
       (L:LEFT_LANLITE_SELECT_POS,number) 25 - (&gt;L:LEFT_LANLITE_SELECT_POS,number)
       (L:LEFT_LANLITE_SELECT_POS,number) 0 &lt;
        if{
          0 (&gt;L:LEFT_LANLITE_SELECT_POS,number)
          }
       els{
          1 (&gt;L:XMLSND1,enum)  
          }
       }        
</CallbackCode>
</MouseRect>
</PartInfo>

<!--learjet24_landing_taxi_right-->

<PartInfo>
      <Name>learjet24_landing_taxi_right</Name>
        <AnimLength>50</AnimLength>
  <Animation>
  <Parameter>
       <Code>
          (L:RIGHT_LANLITE_SELECT_POS,number)
       </Code>
     <Lag>950</Lag>
  </Parameter>
  </Animation>
  <MouseRect>
  <Cursor>Hand</Cursor>
  <TooltipText>Right Landing and Taxi Light Switch</TooltipText>
  <MouseFlags>LeftSingle+LeftDrag+Wheel</MouseFlags>
  <CallbackCode>
     (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:RIGHT_LANLITE_SELECT_MPos, number)         
         }
     (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:RIGHT_LANLITE_SELECT_MPos,number) - 20 + 0 &lt;
          if{
            (L:RIGHT_LANLITE_SELECT_POS,number) 25 + (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
        (M:Y) (&gt;L:RIGHT_LANLITE_SELECT_MPos,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:Y) (L:RIGHT_LANLITE_SELECT_MPos,number) - 20 - 0 &gt;
  if{
   (L:RIGHT_LANLITE_SELECT_POS,number) 25 - (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
   (M:Y) (&gt;L:RIGHT_LANLITE_SELECT_MPos,number)
   (L:RIGHT_LANLITE_SELECT_POS,number) 0 &lt;
   if{
    0 (&gt;L:RIGHT_LANLITE_SELECT_POS,number)
   }
   els{
    1 (&gt;L:XMLSND1,enum)  
   }
  }
}
    (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)  
          }
       }        
</CallbackCode>
</MouseRect>
</PartInfo>
 
They click as they are selected into each position. If you are not doing a sound system, then take out all of the SND.... L:vars and you are good to go.

Bill
 
They click as they are selected into each position. If you are not doing a sound system, then take out all of the SND.... L:vars and you are good to go.

Bill

I apologize as I can see now that I was not clear on what I am trying to effect. I appreciate all the code you've shown me and fore see using it in the near future on a
Su project just getting started. At this point I am trying to tap into two existing aircraft for a 2D panel to run animations and lights so that I can stay with an external aircraft view point for a video shoot.
 
Note that you have short cuts in your sim, and can program in shortcuts also. For instance, Landing Lights 'on' is Control - L.
 
Back
Top