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

Basic Trigger Gauge -- need some assistance

Messages
735
Country
us-texas
I do have a working gauge that triggers an animation (on AI ship object), so at least I have gotten this far.


<Gauge Name="CarrierElevator" Version="1.0">

<Element>
<Select>
<Value>
(A:EXIT OPEN, percent) 5 &gt;
if{ 100 (&gt;L:CVelevator) }
els{ 0 (&gt;L:CVelevator) }
</Value>
</Select>
</Element>

</Gauge>


What I am trying to do is this -- I want to rewrite this with some other toggle command, like PANEL_LIGHTS_TOGGLE for instance. Here is one of my attempts:



<Gauge Name="CarrierElevator" Version="1.0">

<Element>
<Select>
<Value>
(A: PANEL_LIGHTS_TOGGLE, bool) 1 ==
if { 1 (&gt;L:CVelevator,bool) }
</Value>
</Select>
</Element>

</Gauge>


Could some kind soul correct my bad XML code here? Believe me, I have spent all weekend googling examples, so it isn't for lack of effort.

Cheers,

Mark

PS: I realize there is no space between A: and PANEL but I wanted to avoid having this :P show up on this BB forum, so I added that space to prevent the pink smily.
 
PANEL_LIGHTS_TOGGLE is the command, not the variable.
Try A:LIGHT PANEL, bool instead.
 
Hi,

The SDK will give you a list of those variable names - very useful.
 
Yes, I know all that about the variables and the event ID lists and all that, thanks. New at this, but not that new. Pretty dumb that I mixed them up, but I had just noticed it when Doug posted his reply.

What I don't know is XMl... so I would benefit with some real elementary assistance there!

A couple Syntax questions here --

1. should there be no space after the if and the { 1 (DothisAction, bool) }? (see below):

if { 1 (&gt;L:CVelevator, bool) }


2. Is there a space before 'bool' ? Do I even need this 'bool' in there?


3. Also do I need that '&gt' here? Would this work as if{ 1 (L:CVelevator, bool) } ?
 
OK so this works, only not like I want/need it to work :

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

    <Element>
        <Select>
            <Value>
                (A:LIGHT PANEL,bool) 1 ==
                if{ 1 (&gt;L:CVelevator) }
                els{ 0 (&gt;L:CVelevator) }
            </Value>
        </Select>
    </Element>

</Gauge>

I have an animation, called CVelevator, that is 360 frames in length. It responds to this toggle command (turning on/off the panel lights) but it only moves one 1 frame.

How would I make the animation move all 360 frames, then, using a toggle command?

Sorry for being so uneducated in XML code, it really isn't my normal sandbox that I play in, but it is interesting!
 
You could try this.
As it sits now it will take approx 20 seconds to get to the 360 frame mark likewise back down to zero.
Adjust the "1" in the if/els for higher or slower speeds.

Code:
<Gauge Name="CarrierElevator" Version="1.0">
    <Element>
        <Select>
            <Value>
                (A:LIGHT PANEL,bool) 1 ==
                if{ (L:CVelevator) 1 + 360 min (&gt;L:CVelevator) }
                els{ (L:CVelevator) 1 - 0 max (&gt;L:CVelevator)  }
            </Value>
        </Select>
    </Element>
</Gauge>
 
Last edited:
Just noticed this in the thread below mine -- helpful for sure!

https://forums.vrsimulations.com/support/index.php/TacPack_SDK#FSX_XML_Syntax_Checking

EDIT: well maybe helpful, we will see. Amazed how many errors were registered by big-name pay-ware aircraft -- so many I had to deactivate the tool in my P3D.CFG file.

To answer some of your questions:
No, there should not be a space between "if" and "{" - unlike some programming/scripting languages, "if" is not a keyword/token, but "if{" is.
Likewise (and some people still miss this) "%" is used for modulo, but when composing a string they see this %(something-or-other)% and believe it is the same token (and therefore it has 2 meaning in XML), it is not. "%" is the module token, "%(" and ")%" are two more, different tokens

No, you do not need a space after the comma in (L:SomeVar,bool) but it is good practice to do so as it makes it somewhat easier to read. Again, using the correct "units" helps both you and XML understand exactly what units you are using.

&gt; is simply markup-language for ">" and is substituted when the file is loaded by FSxx
As ">" is also a token in standard XML, it sometimes confuses the parser and is not guaranteed to work
Just to be annoying, you may come across situations where you actually NEED to change the &gt; to a > when updating an FS9 gauge to work under FSX - fun fun fun

(L:SomeVar, units) means "fetch the value of Somevar and put it on the stack"
(>L:SomeVar, units) [or (&gt;L:SomeVar, units) ] means "take the value currently on the stack and store it in SomeVar), so it must be there if you are storing a value.

GaugeDevDebug=1 is useful if your gauge is written in FSX XML, whereas many many gauges are still written in FS9 XML and will be "kicked out" by the GaugeDevDebug statement even though they work perfectly.

To pre-empt your next question: Although FSX XML is superior in so many ways, many people still write in FS9 XML either out of habit, because they copy/paste/modify existing gauges and code snippets, or because they want their gauges to run on both FS9 and FSX. The choice is, ultimately, up to you. Some will try to tell you that FSX XML is "bloated" and "unworkable" but it is often faster and easier to debug/modify than FS9 XML, especially if your editor allows you to have "templates" for common code sections, e.g. strings.
 
You could try this.
As it sits now it will take approx 20 seconds to get to the 360 frame mark likewise back down to zero.
Adjust the "1" in the if/els for higher or slower speeds.

Code:
<Gauge Name="CarrierElevator" Version="1.0">
    <Element>
        <Select>
            <Value>
                (A:LIGHT PANEL,bool) 1 ==
                if{ (L:CVelevator) 1 + 360 min (&gt;L:CVelevator) }
                els{ (L:CVelevator) 1 - 0 max (&gt;L:CVelevator)  }
            </Value>
        </Select>
    </Element>
</Gauge>

Roman, thank you sir. Could explain this a bit more? How does this affect higher and lower speeds? This '1 + 360 max' what does it do/say?

This did not make the animation move at all by the way, but think we are on the right track here.
 
Last edited:
No, you do not need a space after the comma in (L:SomeVar,bool) but it is good practice to do so as it makes it somewhat easier to read. Again, using the correct "units" helps both you and XML understand exactly what units you are using.

OK thanks that helps. Although I am not sure I need bool for my L:SomeVar.

Really all I am trying to trigger an animation on another simobject. And that animation 360 frames long, so I am not sure if that is relevant.

Code:
<Animation name="CVN_elevator" guid="8591a65c-8f98-4bc8-9b0f-6a62a9841bd4" length="360" type="Sim" typeParam2="CVN_elevator" typeParam="AutoPlay" />

    <PartInfo>
    <Name>CVN_elevator</Name>
    <AnimLength>360</AnimLength>
    <Animation>
        <Parameter>
         <Code>
           (L:CVelevator)
          </Code>
         <Lag>15</Lag>
        </Parameter>
    </Animation>
    </PartInfo>

So is L:CVelevator looking for a value here?

When I first tried this, I used another variable to trigger it. It was the EXIT OPEN variable, which is measured in percent. You will see it shown in my first post above. The result was that the animated part WAS triggered by it moved only about 100 frames.

Then I ran another experiment, using a Bool variable, and it only moved 1 frame. You'll see that in post #7 above.

So I gather that there IS a value being assign to L:CVelevator, and my animation code (above) is taking that value and using it as a max length of my animation.
 
Likewise (and some people still miss this) "%" is used for modulo, but when composing a string they see this %(something-or-other)% and believe it is the same token (and therefore it has 2 meaning in XML), it is not. "%" is the module token, "%(" and ")%" are two more, different tokens

In strings, "%(" and ")%" are not tokens, actually; only "%" is. Which combined with "(" or "!" or "{" is telling the parser that following text is a script, or a value, or a conditional evaluator.

As ">" is also a token in standard XML, it sometimes confuses the parser and is not guaranteed to work

Actually " > " works always, parser is never confused. It's that some older HTML editors didn't support it the reason to include a substitute "&gt;". On the other hand, " < " won't work ever and "&lt;" must be used instead.

Although FSX XML is superior in so many ways

The only reason for FSX XML schema to exists is the ability to be interpreted by ACE editor that comes in that version, and also possible to be precompiled into .spb format's pseudocode, which improves a bit gauge loading when aircraft is selected.
Appart from that, there are no other noticeable advantages. And being so verbosed and extensive compared to FS9 version is a real drawback. Unless there is a need to use <CustomDraw> properties coming from G1000 XML source, I would not recommend it to new coders if they are going to work with "standard" gauges (90% of XML universe).

Tom
 
So is L:CVelevator looking for a value here?

When I first tried this, I used another variable to trigger it. It was the EXIT OPEN variable, which is measured in percent. You will see it shown in my first post above. The result was that the animated part WAS triggered by it moved only about 100 frames.

If your animation is 360 frames long, then L:CVelevator should be in 0-360 range. As EXIT OPEN variable goes from 0 to 100 % you can now understand why the animation moved only from 0 to 100 frames.

Tom
 
If your animation is 360 frames long, then L:CVelevator should be in 0-360 range. As EXIT OPEN variable goes from 0 to 100 % you can now understand why the animation moved only from 0 to 100 frames.

Tom

Yes, and my 'toggle whatever' bool variable is ZERO or ONE, so I can also understand why the animation moved only 1 frame.

Ok so then now do I make the thing accept a value of 360?
 
It depends on how you want your animation to respond to commands. For example, when you toggle PANEL LIGHT, do you want to move from 0 to 360: slow? fast? how?
I (or Roman as well) could help you better if you describe in detail what is the animation supposed to do.

Tom
 
Would this not work?

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

    <Element>
        <Select>
            <Value>
                (A:LIGHT PANEL,bool) 1 ==
                if{ 360 (&gt;L:CVelevator) }
                els{ 0 (&gt;L:CVelevator) }
            </Value>
        </Select>
    </Element>

</Gauge>


Is this basically saying OK IF Boolean Variable is TRUE (=1) THEN DO IF{do stuff}, and if not, THEN DO ELS{do stuff}?

What I hope this next line says is that IF TRUE, then Set this L:Variable to value of 360. At least that is what I am trying to achieve.
 
It depends on how you want your animation to respond to commands. For example, when you toggle PANEL LIGHT, do you want to move from 0 to 360: slow? fast? how?
I (or Roman as well) could help you better if you describe in detail what is the animation supposed to do.

Tom

I see. I wondered by Roman asked about the speed of the animation.

I want it to move slowly, yes. This is a carrier platform elevator, and it should move slowly.
 
Pretty sure what I used in post #16 worked, but I had to use Nav Lights instead -- that is because the R-66 I used didn't have the Panel Lights listed in the aircraft.CFG file

(A:LIGHT NAV,bool) 1 ==

SHAZAM!

OK, now need to test this with other aircraft and other lights.
 
Back
Top