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

Conditional Animations

Messages
177
Country
unitedkingdom
Hi,

I don't know what else to call them. :o

Guarded switches are the best example; how do you make it so that a switch does not move until a guard has been released? XML gauge programming is the lesser of my talents, and I suspect it requires a bit of XML magic?? I can just about cope with creating a custom animation with a bit of copying and pasting (not good I know!!!). :o

Best regards,
Robin.
 
It's simple enough. You simply need to add your "special condition" to the XML <CallbackCode> script.

The first code blob is for the "Guarded Cover" and the second code blob shows how to add the "special condition" to the mouse <CallbackCode> so it will only work if the "Guarded Cover" is open.

Code:
    <PartInfo>
        <Name>switch_cover</Name>
	  <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                    (L:SwitchCover,number) 50 *
                </Code>
		    <Lag>200</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
		<TooltipText>Open/Close Cover</TooltipText>
		<CallbackCode>(L:SwitchCover,number) ! (&gt;L:SwitchCover,number)</CallbackCode>
        </MouseRect>
    </PartInfo>

    <PartInfo>
        <Name>switch_master_battery</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>ELECTRICAL MASTER BATTERY</Variable>
                    <Units>bool</Units>
                    <Scale>50</Scale>
                </Sim>
                <Lag>400</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <HelpID>HELPID_GAUGE_BATTERY_SWITCH</HelpID>
            <TooltipID>TOOLTIPTEXT_BATTERY_SWITCH</TooltipID>
            <CallbackCode>
                (L:SwitchCover,number) 
                    if { >K:TOGGLE_MASTER_BATTERY }
            </CallbackCode>
        </MouseRect>
    </PartInfo>
 
<CallbackCode>
(L:SwitchCover,number)
if { >K:TOGGLE_MASTER_BATTERY }
</CallbackCode>]
:confused:

Is there anything in the FS SDK that explains the XML code formatting? Why is it even written backwards? :confused:

Best regards,
Robin.
 
:confused:

Is there anything in the FS SDK that explains the XML code formatting? Why is it even written backwards? :confused:

Best regards,
Robin.

Robin, XML is written in "Reverse Polish Notation," which is a throwback to the early Hewlet Packard calculators...

Actually, since XML is written around the "stack" model, RPN is more efficient.

For detailed XML code writing, see http://fs2x.com/Tutorials.htm

There is also a tool in the SDK which will allow you to write an expression in C# (forward notation) and with a mouse click have it "translated" to RPN.

Although these tutorial exercises and examples are based on "gauge code," the principles remain the same for the XML used in the modeldef.xml file.
 
Last edited:
Actually, since XML is written around the "stack" model, RPN is more efficient.
Now that makes sense! :)

There is a tool in the SDK
Excellent! I shall look for it. :) I've no problem coding in C#.

Thanks for that snippet of information - it makes things a bit clearer now!! :D

Best regards,
Robin.
 
Back
Top