1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Conditional Animations

Discussion in 'Modeling' started by VulcanB2, 11/12/07.

  1. VulcanB2

    VulcanB2

    Joined:
    24/12/05
    Messages:
    177
    Country:
    unitedkingdom
    Hi,

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

    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!!!). :eek:

    Best regards,
    Robin.
  2. n4gix

    n4gix Resource contributor

    Joined:
    26/9/06
    Messages:
    9,342
    Country:
    unitedstates
    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>
    
    
  3. VulcanB2

    VulcanB2

    Joined:
    24/12/05
    Messages:
    177
    Country:
    unitedkingdom
    :confused:

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

    Best regards,
    Robin.
  4. n4gix

    n4gix Resource contributor

    Joined:
    26/9/06
    Messages:
    9,342
    Country:
    unitedstates
    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: 13/12/07
  5. VulcanB2

    VulcanB2

    Joined:
    24/12/05
    Messages:
    177
    Country:
    unitedkingdom
    Now that makes sense! :)

    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.

Share This Page