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

MSFS20 Cockpit flood lights

Messages
236
Country
australia
Hi all, quick question if anyone has a second. I have a rotary knob on my overhead panel which controls cockpit flood lighting, it is labeled : LIGHTING_Knob_SidePanel
I use the following to control it and it works perfectly.

<Component ID="SIDE_PANEL">
<DefaultTemplateParameters>
<POTENTIOMETER>6</POTENTIOMETER>
</DefaultTemplateParameters>
<UseTemplate Name="ASOBO_LIGHTING_Knob_Potentiometer_Template">
<NODE_ID>LIGHTING_Knob_SidePanel</NODE_ID>
<ANIM_NAME>LIGHTING_Knob_SidePanel</ANIM_NAME>
<TOOLTIP_TITLE>@TT_Package.LIGHTING_SWITCH_LIGHT_SIDEPANEL_BRIGHTNESS_TITLE</TOOLTIP_TITLE>
<TT_DESCRIPTION_ID>@TT_Package.LIGHTING_SWITCH_LIGHT_SIDEPANEL_BRIGHTNESS_ACTION</TT_DESCRIPTION_ID>
</UseTemplate>
<UseTemplate Name="ASOBO_LIGHTING_Panel_Emissive_Template">
<NODE_ID>LIGHTING_Breakers_Emissive</NODE_ID>
</UseTemplate>
</Component>

However, one thing is driving me absolutely crazy, It only works after the toggle lights button is pressed, i.e. SHIFT+L in my case.
After that it works as it should. Is there any way I can get it to work without having to toggle all lights?
Thanks in advance TJ
 
I think your knob controls the intensity. If the light isn't on then it's not going to do anything. This is why it appears to work when you turn all the lights on. Because you aren't actually turning it off when you rotate the knob, you're just dimming it down to nothing.

You will need some code that turns the light on when the knob is above a certain level and turns it off again when it's below that level.
 
Yes, I have a very similar issue. It is a rocker switch, no intensity involved. However there is a glitch. In one model it works every time, after I have switched it on once. In the other model, it is as it is for you, I must first toggle aircraft lights. The distinct difference between the two is that the model with the default lights from the sample project works without toggling lights first.

I'm pretty poor when it comes to deciphering templates, but it looks like you have only pasted a partial code to control your light. I created mine in partnership with ChatGPT, so it's likely to be clunky and artificial, but it has essentially three component ID's, one for the switch, one for the cabin light state and one to make the lightbulb itself light up. Mine uses the condition of <CONDITION>(A:LIGHT CABIN ON, bool)</CONDITION> and it suggests a different condition would not be dependant on the default light state, that could just override whatever state had been pre existing, but I'm only guessing here.


 
Great points Anthony and RK. I was going along the lines of forcing the light intensity to zero but couldn't work out the code to do so. Will do some digging and report back. Many thanks.
 
Yes, I have a very similar issue. It is a rocker switch, no intensity involved. However there is a glitch. In one model it works every time, after I have switched it on once. In the other model, it is as it is for you, I must first toggle aircraft lights. The distinct difference between the two is that the model with the default lights from the sample project works without toggling lights first.

I'm pretty poor when it comes to deciphering templates, but it looks like you have only pasted a partial code to control your light. I created mine in partnership with ChatGPT, so it's likely to be clunky and artificial, but it has essentially three component ID's, one for the switch, one for the cabin light state and one to make the lightbulb itself light up. Mine uses the condition of <CONDITION>(A:LIGHT CABIN ON, bool)</CONDITION> and it suggests a different condition would not be dependant on the default light state, that could just override whatever state had been pre existing, but I'm only guessing here.


Rick, I am building off the default sample. Could that have something to do with it?
 
I think your knob controls the intensity. If the light isn't on then it's not going to do anything. This is why it appears to work when you turn all the lights on. Because you aren't actually turning it off when you rotate the knob, you're just dimming it down to nothing.

You will need some code that turns the light on when the knob is above a certain level and turns it off again when it's below that level.
Anthony, have you any idea on what code I could possibly use to toggle All lights. There seem to be no variables that I can find to do that. So far I have gone into the systems.config to find the particular potentiometer that I need to control.
From my systems.cfg, I need to control potentiometer 4

I have an initialization gauge that I am using. In it I am using the following element:

<Element>
<Select>
<Value>
(A:ELECTRICAL MASTER BATTERY,Bool) 1;
if{ 100 * (&gt;K:4:LIGHT_POTENTIOMETER_SET) }
els{ 0 }
</Value>
</Select>
</Element>

All this seems to do is when I roll the middle mouse button over the knob, I get a disco which seems to me that is firing the potentiometer variable then resetting to zero immediately after.

As you can see, I am stumped on two fronts, first, I need to toggle lights to start and second, I need to turn the potentiometer down to zero when the battery comes on.

Can you possibly assist?

Many thanks
 
Rick, I am building off the default sample. Could that have something to do with it?
Yes, I don't think so. I am only guessing but it seems like <CONDITION>(A:LIGHT CABIN ON, bool)</CONDITION> is a query and not setting the state, as in "if light is on yes or no." So by extension, using the keyboard command for lights or flipping the switch once with no apparent result, sets that condition to "yes" and from there the light works as we expect. If you read the little thumbnail of the YouTube video it says, "logic to control the light based on the SIMVAR." I didn't type that comment, ChatGPT did, presumably from some other developer, but it supports my assumption. So instead of (A:LIGHT CABIN ON, bool) we'd want (L:CABIN LIGHT SWITCH ON, bool) or something similar.
 
Yes, I don't think so. I am only guessing but it seems like <CONDITION>(A:LIGHT CABIN ON, bool)</CONDITION> is a query and not setting the state, as in "if light is on yes or no." So by extension, using the keyboard command for lights or flipping the switch once with no apparent result, sets that condition to "yes" and from there the light works as we expect. If you read the little thumbnail of the YouTube video it says, "logic to control the light based on the SIMVAR." I didn't type that comment, ChatGPT did, presumably from some other developer, but it supports my assumption. So instead of (A:LIGHT CABIN ON, bool) we'd want (L:CABIN LIGHT SWITCH ON, bool) or something similar.
Thanks Rick, I'll give it a go tonight. These templates are damn frustrating. Cheers
 
Anthony, have you any idea on what code I could possibly use to toggle All lights. There seem to be no variables that I can find to do that. So far I have gone into the systems.config to find the particular potentiometer that I need to control.
From my systems.cfg, I need to control potentiometer 4

I have an initialization gauge that I am using. In it I am using the following element:

<Element>
<Select>
<Value>
(A:ELECTRICAL MASTER BATTERY,Bool) 1;
if{ 100 * (&gt;K:4:LIGHT_POTENTIOMETER_SET) }
els{ 0 }
</Value>
</Select>
</Element>

All this seems to do is when I roll the middle mouse button over the knob, I get a disco which seems to me that is firing the potentiometer variable then resetting to zero immediately after.

As you can see, I am stumped on two fronts, first, I need to toggle lights to start and second, I need to turn the potentiometer down to zero when the battery comes on.

Can you possibly assist?

Many thanks
You may like to use the .FLT configs. Depending on how the user starts the flight the sim is going to load the appropriate .FLT files. You can set the lights and potentiometer values in the .FLT. Easiest way to do this is save a flight with the config you need and then open the .FLT and copy the values in the the starting .FLT files. The lights and potentiometer values will be in the [Switches.0] section of the .FLT file.

Your code is wrong too (I assume it runs only once otherwise it will always be setting the pot to 100

Code:
 (A:ELECTRICAL MASTER BATTERY,Bool)

        if{ 100 (&gt;K:4:LIGHT_POTENTIOMETER_SET)  }

       els{ 0 (&gt;K:4:LIGHT_POTENTIOMETER_SET) }

Your other option is to use some update code

Check if the pot is below, say, 10 and if the light is on turn it off. else, if the light is off turn it on. This would be the simplest way to switch the light on and off depending on the knob position.

This doesn't solve one other problem you have which is what happens if the user uses a key command to toggle all lights on? In this case you will probably want to set the potentiometer to 100%.

To cover that case what I do is write some complicated code. The following uses my own custom templates but it should give you an idea of what is involved:

Code:
            <CODEINC>
                (A:LIGHT PANEL:1,number) 0 == if{ 100 (&gt;K:LIGHT_POTENTIOMETER_6_SET) } els{ 6 (&gt;K:LIGHT_POTENTIOMETER_INC) }
                (A:LIGHT POTENTIOMETER:6,percent) 99.9 &gt; (A:LIGHT PANEL:1,number) 0 == &amp; if{ 1 (&gt;K:PANEL_LIGHTS_ON) 30 (&gt;L:winjeel_uv_light_left_offset,number) }
            </CODEINC>
            <CODEDEC>
                6 (&gt;K:LIGHT_POTENTIOMETER_DEC) (A:LIGHT POTENTIOMETER:6,percent) 1 &lt; if{ 1 (&gt;K:PANEL_LIGHTS_OFF) }
            </CODEDEC>
            <CODESET>p0 (&gt;K:LIGHT_POTENTIOMETER_6_SET)</CODESET>
            <CODEANIM>
                (L:winjeel_uv_light_left_offset,number) 0 &gt; if{ (L:winjeel_uv_light_left_offset,number) 1 - 0 max (&gt;L:winjeel_uv_light_left_offset,number) }
                (A:LIGHT PANEL:1,number) 0 == if{ 0 } els{ (A:LIGHT POTENTIOMETER:6,percent) (L:winjeel_uv_light_left_offset,number) + }               
            </CODEANIM>

The panel lights are turned on and off depending on the knob position (note that if the light is off the pot goes to 100 because that is how these UV lights work, you have to turn the knob all the way on to kick in the starter for the lights. This is what L:winjeel_uv_light_left_offset handles, you can ignore any references to this variable in your own code.

In the anim code it checks if the panel light is on or off. If off it sets the knob to zero, otherwise it uses the pot position. This code handles switching the lights on and off depending on the knob position while also accounting for the user using a key command to switch the panel lights on and off.
 
You may like to use the .FLT configs. Depending on how the user starts the flight the sim is going to load the appropriate .FLT files. You can set the lights and potentiometer values in the .FLT. Easiest way to do this is save a flight with the config you need and then open the .FLT and copy the values in the the starting .FLT files. The lights and potentiometer values will be in the [Switches.0] section of the .FLT file.

Your code is wrong too (I assume it runs only once otherwise it will always be setting the pot to 100

Code:
 (A:ELECTRICAL MASTER BATTERY,Bool)

        if{ 100 (&gt;K:4:LIGHT_POTENTIOMETER_SET)  }

       els{ 0 (&gt;K:4:LIGHT_POTENTIOMETER_SET) }

Your other option is to use some update code

Check if the pot is below, say, 10 and if the light is on turn it off. else, if the light is off turn it on. This would be the simplest way to switch the light on and off depending on the knob position.

This doesn't solve one other problem you have which is what happens if the user uses a key command to toggle all lights on? In this case you will probably want to set the potentiometer to 100%.

To cover that case what I do is write some complicated code. The following uses my own custom templates but it should give you an idea of what is involved:

Code:
            <CODEINC>
                (A:LIGHT PANEL:1,number) 0 == if{ 100 (&gt;K:LIGHT_POTENTIOMETER_6_SET) } els{ 6 (&gt;K:LIGHT_POTENTIOMETER_INC) }
                (A:LIGHT POTENTIOMETER:6,percent) 99.9 &gt; (A:LIGHT PANEL:1,number) 0 == &amp; if{ 1 (&gt;K:PANEL_LIGHTS_ON) 30 (&gt;L:winjeel_uv_light_left_offset,number) }
            </CODEINC>
            <CODEDEC>
                6 (&gt;K:LIGHT_POTENTIOMETER_DEC) (A:LIGHT POTENTIOMETER:6,percent) 1 &lt; if{ 1 (&gt;K:PANEL_LIGHTS_OFF) }
            </CODEDEC>
            <CODESET>p0 (&gt;K:LIGHT_POTENTIOMETER_6_SET)</CODESET>
            <CODEANIM>
                (L:winjeel_uv_light_left_offset,number) 0 &gt; if{ (L:winjeel_uv_light_left_offset,number) 1 - 0 max (&gt;L:winjeel_uv_light_left_offset,number) }
                (A:LIGHT PANEL:1,number) 0 == if{ 0 } els{ (A:LIGHT POTENTIOMETER:6,percent) (L:winjeel_uv_light_left_offset,number) + }              
            </CODEANIM>

The panel lights are turned on and off depending on the knob position (note that if the light is off the pot goes to 100 because that is how these UV lights work, you have to turn the knob all the way on to kick in the starter for the lights. This is what L:winjeel_uv_light_left_offset handles, you can ignore any references to this variable in your own code.

In the anim code it checks if the panel light is on or off. If off it sets the knob to zero, otherwise it uses the pot position. This code handles switching the lights on and off depending on the knob position while also accounting for the user using a key command to switch the panel lights on and off.
You sir are the steely eyed missle man. Thank you so much. Will try tonight. Thanks again.
 
your shift + L, to turn ON "all light". if you want to light ON without shift + L, you need to turn ON your light in you code that you attach in system.cfg

this the base idea to work with, in your case is flood flight.
1. usually I use aircraft cabin light variable (Avar) to tie flood light, make sure this ON
2. light beam brightness are controlled by Potentiometer (0-100)
3. if your model need to emit as light source, you need NODE_ID and emissive texture, along with control from potentiometer.

this code to turn light of the cabin (stock code)
XML:
<Include ModelBehaviorFile="Asobo\Common.xml"/>

<UseTemplate Name="ASOBO_LIGHTING_Switch_Light_Cabin_Template"/>

this for emissive light
XML:
<Component ID="Node_Emissive_name">
    <Parameters Type="Default">
        <NODE_ID>node_emissive_name</NODE_ID>
    </Parameters>
    <Component ID="#NODE_ID#_emis" Node="#NODE_ID#">
        <UseTemplate Name="ASOBO_GT_Emissive_Gauge">
        <EMISSIVE_CODE> (L:your_potentiometer, enum) 0.01 * </EMISSIVE_CODE>
        </UseTemplate>
    </Component>               
</Component>
 
Back
Top