• 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 Set LVar value to 1 without update code?

Rotornut44

Resource contributor
Messages
637
Country
us-florida
This is a duplicate of my thread on the DevSupport Forums. Posting here to try to reach more people who might know an answer to this...

Is there a way that I can set a LocalVar to a value of 1 without relying on update code in the XML?

I need to pass a 1 for an LVar in my scenery simobject when a certain condition is met, to tie it into a Wwise sound, however Update Code does not seem to work outside of aircraft, and those are the only examples I can find, so I'm unsure how to go about setting this value...

Using my current update code, I can see the LVar in the Behaviors menu in sim, but the value is stuck to 0.

Code:
<Component ID="CAMPFIRE_LVAR_UPDATE">
<UseTemplate Name="ASOBO_GT_Update">
<FREQUENCY>30</FREQUENCY>
<UPDATE_CODE>
(A:AMBIENT TEMPERATURE, celsius) 10 &lt;=
if{                 
1 (&gt;L:CAMPFIRE_ACTIVE)
} els{                 
0 (&gt;L:CAMPFIRE_ACTIVE)
}
</UPDATE_CODE>
</UseTemplate>
</Component>


Any ideas? (I am aware that I can use a SimVar in the Wwise XML for this A:var, but I still need this L:var method to work for other SimObjects!)

Also, why couldn't you use some code like the following to make this work? Maybe my XML structure isn't right, but even something as simple as this, that I would think would work does not:

Code:
<Component ID="CAMPFIRE_WWISE">
<Visibility>
<Parameter>
<Code>(A:AMBIENT TEMPERATURE, celsius) 10 &lt;= if{ 1 (L:CAMPFIRE_ACTIVE) }</Code>
</Parameter>
</Visibility>
</Component>

I don't understand why it would be so difficult to get something like this working. 6 days I've been trying to solve this... I've sat down with 2 aircraft developers that do nothing but XML, and we've found many solutions, but none work when it comes to scenery. Probably because they rely on some sort of update code to work.
 

Rotornut44

Resource contributor
Messages
637
Country
us-florida
Trivial but, Campfire has no unit, maybe?(bool, number..ect)
Supposedly that is no longer required. And I know my first update code snippet works when it's used in an aircraft. Just not in a scenery.
 
Messages
1,056
Country
australia
Code:
1 (&gt;L:CAMPFIRE_ACTIVE)

Your original code is not writing into the L var. The above will. It still probably won't work.

The reason L vars are local to the aircraft is because you don't want other users aircraft in multiplayer messing with your own aircraft.
 

rhumbaflappy

Administrator
Staff member
Resource contributor
Messages
5,947
Country
us-wisconsin
I believe you can use L vars in an object's code, but it will refer to the User aircraft, not the object, and must exist in the User aircraft's code. Asobo indicated they might add more usage to scenery SimObjects, but they have not done that yet.
 

Rotornut44

Resource contributor
Messages
637
Country
us-florida
I believe you can use L vars in an object's code, but it will refer to the User aircraft, not the object, and must exist in the User aircraft's code. Asobo indicated they might add more usage to scenery SimObjects, but they have not done that yet.
Well. Darn. It's always the last piece of the puzzle that's missing...
I have this other thread over on Devsupport, which is the other side of this conversation (Wwise). FlyingRaccoon seems to indicate that it's possible, but although I made it clear, maybe Sylvain just confused it as being an aircraft question? I didnt really get any answers other than pointing to the SDK.
Would you happen to know where it was talked about adding more usage to scenery SimObjects? If there is a physical discussion, I'd love to add to it...
 

rhumbaflappy

Administrator
Staff member
Resource contributor
Messages
5,947
Country
us-wisconsin
Here's a code that opens a hangar door when the aircraft's yoke is hidden. But it depends on the aircraft having the hidden yoke feature:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<ModelInfo version="1.1" guid="{7db8db69-29e2-44a0-baec-6979bf6d5bc0}">

    <LODS>
        <LOD minSize="0" ModelFile="SimpleHangar.gltf"/>
    </LODS>

    <Animation guid="080AB0CF-D301-4687-B81C-E3DE54E39761" length="100" name="DoorLeft" type="Sim" typeParam="AutoPlay" typeParam2="DoorLeft"/>
    <Animation guid="C5E04568-CB84-454F-A2F0-7CF3175B78C9" length="100" name="DoorRight" type="Sim" typeParam="AutoPlay" typeParam2="DoorRight"/>

    <AnimGraph>
        <DefaultState name="SimpleHangar_Close"/>
        <BlendTreeState name="SimpleHangar_Close">
          <Animations>
            <Animation guid="080AB0CF-D301-4687-B81C-E3DE54E39761" loop="False" speed="1"/>
            <Animation guid="C5E04568-CB84-454F-A2F0-7CF3175B78C9" loop="False" speed="1"/>
          </Animations>
        </BlendTreeState>
    </AnimGraph>

    <PartInfo>
        <Name>DoorLeft</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                (L:XMLVAR_YokeHidden1) 1 == if{ 50 } els{ 0 }
                </Code>
                <Lag>10</Lag>
            </Parameter>
        </Animation>
    </PartInfo>
    <PartInfo>
        <Name>DoorRight</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                (L:XMLVAR_YokeHidden1) 1 == if{ 50 } els{ 0 }
                </Code>
                <Lag>10</Lag>
            </Parameter>
        </Animation>
    </PartInfo>

</ModelInfo>

(L:XMLVAR_YokeHidden1) 1 == if{ 50 } els{ 0 } reads the L: variable of the User aircraft, and then animates the hangar door accordingly. I haven't further tested L: vars, but I guess they all refer to the user aircraft. not scenery SimObjects.
 
Top