PDA

View Full Version : Conditional Animations


VulcanB2
11 Dec 2007, 18:51
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.

n4gix
12 Dec 2007, 00:36
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.


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

VulcanB2
12 Dec 2007, 13:10
<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.

n4gix
12 Dec 2007, 20:19
: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.

VulcanB2
13 Dec 2007, 07:22
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.