• 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 Landing Light Coding Question

Messages
109
I have a landing light that is supposed to display when landing light is turned on, with gear extended, and once the gear retracts beyond 90%, automatically turns off. I borrowed working code for the FS9 version of the same model and attempted to covert it for use in XtoMDL. The compiled model shows the landing light on/off with lights selected accordingly, however it doesn't turn off once gear is retracted as it should. I've checked examples of FS9 vs. FSX xml coding and managed to get some items working, but this one eludes me. Any assistance is appreciated.

Code:
<PartInfo>
	<Name>attachpt_landing_1</Name>
	<Animation>
		<Parameter>
			<Code>
                            (A:LIGHT LANDING,number) (A:GEAR CENTER POSITION,PERCENT) 90 &lt;
                            if{ (A:LIGHT LANDING,number) 0 &gt; if{ (&gt;K:LANDING_GEAR_TOGGLE) } } 
 			</Code>
		</Parameter>
	</Animation>
</PartInfo>
 
This one is one I'm using as the taxi lights as they are linked to the main gear.

Code:
    <PartInfo>
        <Name>light_taxi</Name>
        <AnimLength>100</AnimLength>
        <Visibility>
            <Parameter>
        	<Code>
			(A:ELECTRICAL MASTER BATTERY, bool)
			(A:LIGHT TAXI, bool)
			(A:Gear left position,percent)  20 &gt;
			and
			and
			 </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

You maybe need to tweak the (A:Gear left position,percent) 20 &gt; to any number you like.
That code turns of the light as it enters the wing.
 
Last edited:
Many thanks for the code, it resolved half of the issue! The model features an illuminated cover piece (named "landlighton") that displays in conjunction with landing lights being on, therefore using the same code to be used but with a simple part name change. With the modified code presented here, it works beautifully; however, the actual "attachpoint" parts (the working landing and taxi lights) still display on whether gear is retracted or extended. In other words, this code has proven to work with conventional parts in the project, however when it comes to attachpoint parts, they seem to ignore the conditions assigned to them when compiled with XtoMDL. I'm compiling with FSDS V3.5.1 (also experimenting with 3.5.2). Once again, thanks for any advice. If it helps, here is the now-working code for the light cover part:

Code:
<PartInfo>
        <Name>landlighton</Name>
        <AnimLength>100</AnimLength>
        <Visibility>
            <Parameter>
        	<Code>
			(A:ELECTRICAL MASTER BATTERY, bool)
			(A:LIGHT LANDING, bool)
			(A:GEAR CENTER POSITION,PERCENT) 90 &gt;
			and
			and
			 </Code>
            </Parameter>
        </Visibility>
</PartInfo>
 
Back again,

I am trying to use similar code to what was posted just above, for use with the FS9 MakeMDL compiler. Obviously it has to be converted properly...I've been attempting to mess with it for a couple of days now and cannot get it working. It seems the code should look something like this (below), must be something out of order as it still does not work. Any suggestions are appreciated. (The part is an illuminated cover piece intended to display when the landing light is toggled on/off, as well as when the gear is retracted.)

Code:
<part>
        <name>landlighton</Name>
        <visible_in_range>
            <parameter>
        	<code>
			(A:ELECTRICAL MASTER BATTERY, bool)
			(A:LIGHT LANDING, bool)
			(A:GEAR CENTER POSITION,PERCENT) 90 &gt;
			and
			and
			 </code>
            </parameter>
        <minvalue>1</minvalue> 
        <maxvalue>1</maxvalue> 
        </visible_in_range>
</part>
 
I'm pretty sure that your min and max value cannot both be 1? I use 0 and -1, but I do the inverse: use conditions where I *don't* want it to display.
 
Got it sorted.

Turns out (for FS9 anyhow) the parts displaying conditionally cannot be children parts. The gear light cover part was modeled in the down position with no animation and with the following code added to MakeMDL:

Code:
<part>  
 <name>gearlightsdown</name>  
  <visible_in_range>  
    <parameter>  
      <code>
          (A:LIGHT LANDING,number) (A:GEAR CENTER POSITION,PERCENT) 99 &lt; 
          if{ (A:LIGHT LANDING,number) 0 &gt; if{ (&gt;K:LANDING_GEAR_TOGGLE) } } 
      </code>  
    </parameter>  
      <minvalue>1</minvalue>
      <maxvalue>1</maxvalue>
  </visible_in_range>
</part>

It now displays when landing light is toggled, and only when gear is in the down position. Am going to try the same with the landing/taxi lights as well as the attachpt parts used in FSX to generate the lighting; this should result in the actual lighting coming on under the same conditions.
 
Sorry for coming back with this, turns out a problem remains when compiling for FSX. Attach points for gear lights were added as static parts with no hierarchy/animation. When test flying, the gear lights remain on whether gear is toggled up or down. Only thing that has any effect is toggling the lights on/off; this is not satisfactory, as the lights are right out in front of the nose gear and remain floating in space below the aircraft with gear up. I changed the lighting parts "attachpt_taxi_1" and "attachpt_landing_1" to be renamed "test_1" and "test_2" and use default material, compiled the model and the revised parts display under the desired conditions (e.g., toggling gear & toggling lights). Also subsequently tested adding keyframe animation to the attachpt parts with no success. Many thanks for any leads.
 
the way i do mine, is create the light poly as normal, but do NOT attatch to the moving gear part.

Now create a smal box, and hide it somewhere near the gear part. Link the box to the gear part, then link your light poly to the box

tag the box with VISABILITY for GEAR GREEN light_gear_left_green

this will make the light poly only be visable when the gear is down and locked. as soon as it starts to retract, the light goes off
 
It's been awhile and I apologize for the delay in replying, but many thanks to ukmil for the post, as this ultimately corrected the problem. I haven't had much time to chip away at the project over the past weeks but found some time this evening to do so, and upon trying out this tip found it worked a treat. Really apprecite it.
 
Back
Top