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

MSFS Custom emissive code to light up button ?

Messages
19
Country
germany
Hi everyone, I am new here :) . I currently started to work on an airplane I modeled , but I struggle with the coding a button that is lighting up a decal when switching it on.
So far I mostly got everything working with templates and those Simvars.

The landing light button when switched on lights up the decal, using the "ASOBO_LIGHTING_Switch_Light_Landing_Template" for the button and "ASOBO_SAFETY_Indicator_Caution_Template" for the decal.

But I also got a passenger heater button that ideally should light light up a decal, but there is no corresponding Simvar.

So the button for the heater is switched on using this template:

Code:
<UseTemplate Name="ASOBO_PASSENGER_Switch_Cabin_Heat_Template">
            <NODE_ID>PASSENGER_Switch_Cabin_Heat_1</NODE_ID>
            <ANIM_NAME>PASSENGER_Switch_Cabin_Heat_1</ANIM_NAME>
        </UseTemplate>

I was hoping to light up the decal using also a template and use the ANIM_NAME from the other template , but it doesnt work at all. This was my attempt, but it is wrong. I admit I am not a coder .

Code:
    <UseTemplate Name="ASOBO_GT_Material_Emissive_Code">
    <NODE_ID>LIGHTING_Heaton</NODE_ID>
            <EMISSIVE_CODE>(L:PASSENGER_Switch_Cabin_Heat_1:1, bool)
            </EMISSIVE_CODE>
    </UseTemplate>

How do I get the decal to light up then ? Thank you for any tips.

br.jpg
 
Messages
1,053
Country
australia
Node ID is not used, you attach the emissive code to the Component ID (which is the name of the part within the modeling program, the Node ID is the reference within MSFS and it can be anything you like, for ease of use here I have made Node and Component ID the same). I've also never seen an L: variable use an index before. Does it work?

Code:
<Component ID="Horizontal_stab_left" Node="Horizontal_stab_left">

    <UseTemplate Name="ASOBO_GT_Material_Emissive_Code">

        <EMISSIVE_CODE>(A:ELEVATOR POSITION,percent)</EMISSIVE_CODE>

    </UseTemplate>

</Component>

For more information please read https://www.fsdeveloper.com/forum/threads/heres-how-to-write-you-own-modelbehavior-code.451037/
 
Messages
19
Country
germany
Yes thank you I read your guide, which is great. But I am still not sure what to use as the Simulation Variable (like "ELEVATOR POSITION" )
I dont find anything for the passenger heat on.

I changed the switch animation code to this:

Code:
            <Component ID="PASSENGER_Switch_Cabin_Heat_1" Node="PASSENGER_Switch_Cabin_Heat_1">
        <UseTemplate Name="ASOBO_PASSENGER_Switch_Cabin_Heat_Template">
            
            <ANIM_NAME>PASSENGER_Switch_Cabin_Heat_1</ANIM_NAME>
        </UseTemplate>
        </Component>

which works,

But the decal with emissive texture is a different part. I tried this, but the Simvar is wrong, because I tried to copy the Component ID from the Passenger_Switch to the Emissive Code.

Code:
<Component ID="LIGHTING_Heaton" Node="LIGHTING_Heaton">

    <UseTemplate Name="ASOBO_GT_Material_Emissive_Code">

        <EMISSIVE_CODE>(A:PASSENGER_Switch_Cabin_Heat_1,percent)</EMISSIVE_CODE>

    </UseTemplate>

    </Component>


I guess I need some sort of code, just like in your tutorial.
Code:
  <Material>
        <EmissiveFactor>
            <Parameter>
                <Code>0 is no emissive, 1 is fully emissive</Code>
            </Parameter>
            <OverrideBaseEmissive>TRUE</OverrideBaseEmissive>
        </EmissiveFactor>
    </Material>

And then Something like <Code> if switch is off no emissive, if switch is on fully emissive</Code> But I struggle there.
 
Messages
1,053
Country
australia
The variable is whatever variable your switch is changing.

A: variables are MSFS variables that are fixed. You cannot make those up.

L: variables are user defined variables. You can make up any name you like for any use you need with L: variables.

Looking at the Passenger_Subtemplates.xml it looks like it resolves down to (L:XMLVAR_CabinHeat_Position_#ID#). So it uses an L: variable. By default the index is 1 (you can change this with the <ID> paramater) so you'd use the variable L:XMLVAR_CabinHeat_Position_1,number. The range of this appear to be 0 to 100 (based on the default anim_length.

Or it could be (L:XMLVAR_CabinHeatSwitch#ID#Status) which is 0 or 1. Actually, looking at the code some more it seems this is the default, an on/off switch. You need to set other parameters to use a lever or knob and they use different variable names.

So the variable you should be using seems to be (L:XMLVAR_CabinHeatSwitch1Status,number)

The code is here if you want to try to decipher it yourself. Look for the <Template Name="ASOBO_PASSENGER_Switch_Cabin_Heat_SubTemplate">

[flight sim path]\Official\OneStore\fs-base-aircraft-common\ModelBehaviorDefs\Asobo\Common\Subtemplates\Passenger_Subtemplates.xml

This is why I never use the MSFS templates. Because it takes more time to decipher the code than it does to write it from scratch.
 
Messages
19
Country
germany
Thank you for your help. Unfortunately when I use those codes it doesnt emit any lights. The more I look at those codes the more confused I get. :)

Maybe it is the wrong approach and there is some other solution. I will keep testing.
 
Messages
5
Country
brazil
@tomlaut1980 Your usage of the "ASOBO_PASSENGER_Switch_Cabin_Heat_Template" template is leading you to this part of the Passenger_Subtemplates.xml:
XML:
<Default>
    <UseTemplate Name="ASOBO_GT_Switch_Code">
        <ANIM_CODE>(L:XMLVAR_CabinHeatSwitch#ID#Status) #ANIM_LENGTH# *</ANIM_CODE>
        <LEFT_SINGLE_CODE>(L:XMLVAR_CabinHeatSwitch#ID#Status) ! (&gt;L:XMLVAR_CabinHeatSwitch#ID#Status)</LEFT_SINGLE_CODE>
        <WWISE_EVENT_1>cabin_heat_switch_on</WWISE_EVENT_1>
        <WWISE_EVENT_2>cabin_heat_switch_off</WWISE_EVENT_2>
    </UseTemplate>
</Default>

So as @Anthony31 said, you need to use "L:XMLVAR_CabinHeatSwitch#ID#Status" variable, so try it like this:
XML:
<Component ID="LIGHTING_Heaton" Node="LIGHTING_Heaton">

    <UseTemplate Name="ASOBO_GT_Material_Emissive_Code">

        <EMISSIVE_CODE>(L:XMLVAR_CabinHeatSwitch1Status)</EMISSIVE_CODE>

    </UseTemplate>

</Component>

This is meaning that Emissive_Code will be what that variable is at that moment, whether 0 or 1. The code is not called only once, it changes dinamically..

Note that it will only work if the "Node=" is the node name of the mesh you want to emit light, so "LIGHTING_Heaton" should be your decal in your 3D modeling software.
 
Messages
19
Country
germany
Hi thanks. Yes " Lighting_Heaton" is the the mesh in my 3D software. Unfortunatley that code <EMISSIVE_CODE>(L:XMLVAR_CabinHeatSwitch1Status)</EMISSIVE_CODE> doesnt emit any light.
I then also tried to change the Switch#ID# and replace the ID with the node name of the ASOBO_PASSENGER_Switch_Cabin_Heat_Template (L:XMLVAR_CabinHeatSwitch#PASSENGER_Switch_Cabin_Heat_1#Status)
in the hope to light something up.

I am also not sure where the "1" for the #ID# comes from. I probably need to define my switch to be switch number 1? Well I now tried to add <ID>1</ID> to the Heater switch, but that didnt do much as well. 🤔
 
Top