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

Need modeldef.XML assistance

Status
Not open for further replies.
Messages
21
Hello again folks! smile

I am now working to get a custom prop "spool up" animation to work. I've completed the animation on a "start up" and "shut down" set of props, did the initial coding in the modeldef using L:var's, created a test gauge and ran the model. Start up looks fine, but I still need to work out the shut down phase of things.

Anyway, I would like to get away from having to use a gauge to trigger the custom animations, and have them trigger when the user starts the engines, (by whatever means, either defaul key commands or gauge) I can't seem to the coding right in the modeldef. I need three condions to be met prior to the L:var animation starting. These are the variables I'm working with.

(A:GENERAL ENG GENERATOR ACTIVE:1, bool)
(A:GENERAL ENG STARTER:1, bool)
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 >

Here is the animation code in the modeldef:

Code:
<PartInfo>
      <Name>prop0_startup</Name>              
        <AnimLength>500</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                (L:C2_PROP0_STARTUP, bool) 500* 
                if{
                (A:GENERAL ENG GENERATOR ACTIVE:1, bool) 1 &gt;
                 AND 
                (A:GENERAL ENG STARTER:1, bool) 1 &gt;
                AND 
                (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; }
                els{ 0 }
                </Code>
                  <Lag>60</Lag>
            </Parameter>
        </Animation>       
     <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Left Prop Start</TooltipText>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode>
        1 (&gt;:L:PROP0_STARTUP, bool)              
      </CallbackCode>
    </MouseRect>
    </PartInfo>

And the visiblity code:

Code:
<PartInfo>
        <Name>prop0_startup_vis</Name>
        <AnimLength>100</AnimLength>
        <Visibility>
            <Parameter>
        	<Code>                 
                  (A:PROP MAX RPM PERCENT:1, percent) 6.25 &lt;
                  (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; &amp;       	  
       	       </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

The visibility aspect works just fine, but the props animation doesn't trigger when the engines are started using key commands. I've run it through the Infix tool with no complaints, and YES, I did read the SDK, but I seem to be missing something!

Any help would be greatly appreciated!

Thanks!!!
 
First of all, this makes no sense at all. A "bool" variable can only ever be either zero or one. It can never be "greater than one..."

Zero means "false" and One means "true". How could anything be "more than true?" :)

Code:
(A:GENERAL ENG GENERATOR ACTIVE:1, bool) 1 &gt;

Second, this variable will never be "one" until the engine is running, IIRC.
 
Ok, revised the code:

Code:
<PartInfo>
      <Name>prop0_startup</Name>              
        <AnimLength>500</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                (L:PROP0_STARTUP, bool) 500*  
                if{                  
                (A:GENERAL ENG STARTER:1, bool) 1   
                AND 
                (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; }
                els{ 0 }
                </Code>
                  <Lag>60</Lag>
            </Parameter>
        </Animation>       
     <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Left Prop Start</TooltipText>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode>
        1 (&gt;:L:PROP0_STARTUP, bool)              
      </CallbackCode>
    </MouseRect>
    </PartInfo>

Still nothing! Is there anything else I should change?
 
Try moving the 'AND to the bottom of the 'second' string of the two that the 'AND' is using. I have only seen 'Ands' placed at the end of stacks, never in between.

Also, try running the XML sheet with a browser like IE and see if it catches a flaw. Usually they will catch mistakes in XML. I think Opera does this also.


Bill
 
Code revised:

Code:
<PartInfo>
      <Name>prop0_startup</Name>              
        <AnimLength>500</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                (L:PROP0_STARTUP, bool) 500*  
                if{                  
                (A:GENERAL ENG STARTER:1, bool) 1
                (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt; }
                AND                
                els{ 0 }
                </Code>
                  <Lag>60</Lag>
            </Parameter>
        </Animation>       
     <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Left Prop Start</TooltipText>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode>         
           (&gt;K:TOGGLE_STARTER1)              
      </CallbackCode>
    </MouseRect>
    </PartInfo>
Still no luck!!!
 
bwest0131;649481 [CODE said:
<Code>
(L:PROP0_STARTUP, bool) 500*
if{
(A:GENERAL ENG STARTER:1, bool) 1
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt; }
AND
els{ 0 }
</Code>
[/CODE]
Still no luck!!!

The parts in red are wrong:

- 500* needs a space , make it 500 *
- 1 has no meaning here.
- AND in caps is not supported, must write and

Following your desires, a basic example on how to code that could be:

Code:
<Code>
  (A:GENERAL ENG GENERATOR ACTIVE:1, bool)
  (A:GENERAL ENG STARTER:1, bool) and 
  (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; and
  if{ 1 (>L:PROP0_STARTUP, bool) }
  els{ 0 (>L:PROP0_STARTUP, bool) }
  (L:PROP0_STARTUP, bool) 500 *
</Code>

Tom
 
Hi Tom,

Tried your method, but no luck either!!! Didn't realize something so simple would turn out to be so hard to achieve!!!! smile

Thanks!
 
It should be simple to achieve as well, but you need to understand how the xml stuff works.

I provided you only a part of the code, and there are others involved that must be properly programmed.

Try by testing whether those three AVars have a proper value...Also make sure the kind of animation you're using is suitable for a rotating prop...etc.

Tom
 
XML coding can be AGRAVATING! Just have to keep moving things around and asking people for help, testing in a browser, etc, etc.

I see that your } bracket is 'inside' of the 'and'. Try moving it to include the 'and'.

Also, you didn't put a space between 500 and * When you have numbers and then symbols on the backs of strings, you must have 'one' space between the groups of numbers and symbols.

Code:
<Code>
(L:PROP0_STARTUP, bool) 500 * 
if{ 
(A:GENERAL ENG STARTER:1, bool) 1
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt; 
AND 
}
els{ 0 }
</Code>
 
Bwest,

Do you know what your code is saying? Its kind of odd. I just read it.

What it is saying is nothing but 'reading', no 'commands';
* Prop0 Startup has run 500 times 'plus'
* General Engine Starter 1 is 'active' or on
* Engine Mixture at engine 1 is at 50%


There are no command strings. A command string usually starts with K: instead of A: If its an L:var you are 'activating or commanding' then it will have a zero or one' in the front, and a > or &gt; in the first part of the string.


Here is an example of some coding that shows 'data' and 'commands'.

Data:

Code:
            (A:GENERAL ENG THROTTLE LEVER POSITION:1,percent)  4 >
            (A:GENERAL ENG THROTTLE LEVER POSITION:1,percent)  2 &lt;
             and  

                      (A:AUTOPILOT AIRSPEED HOLD,bool) 0 == 
                      (A:VELOCITY BODY Z,knot) 85 &gt;
                      and

                      (A:AUTOPILOT AIRSPEED HOLD,bool) 0 == 
                      55 85 (A:VELOCITY BODY Z,knot) rng
                      and

                      (A:AUTOPILOT AIRSPEED HOLD,bool) 0 == 


                      (A:AUTOPILOT AIRSPEED HOLD,bool) 0 == 
                      (A:VELOCITY BODY Z,knot) 85 &gt;
                      and

                      (A:AUTOPILOT AIRSPEED HOLD,bool) 0 == 
                      0 55 (A:VELOCITY BODY Z,knot) rng
                      (A:SIM ON GROUND,bool) 0 ==
                      and and
*note there is an 'and' for each additional string of data*

Commands:
Code:
                1 (>K:TOGGLE_MASTER_BATTERY,bool)  *turns on batt*
                0 (>K:TOGGLE_MASTER_BATTERY,bool)  *turns off batt*
*turns on AP master with number one*
Code:
                      if{
                             1 (&gt;K:AP_MASTER)   
                           }
                      els{ 0 }

Functioning logic string samples;
Code:
   <Element>
            <Select>
            <Value>
                (L:AVEsound_played77,bool) 1 ==
                (A:VELOCITY BODY Z,knot) 96 &gt;
                and
                if{
                0 (&gt;L:AVEsound_played77,bool) 
                3 (&gt;L:XMLSND78,enum) 
                1 (&gt;L:XMLSND78,enum) 
                }
            </Value>
            </Select>
   </Element>


   <Element>
      <Select>
         <Value>
                (A:Avionics master switch,bool) 1 ==
                  if{ 
                      (A:VELOCITY BODY Z,knot) 100 &gt;
                      if{ 
                        0 (>L:WINDOW CONTROL LHF, bool)
                        0 (>L:WINDOW CONTROL RHF, bool)
                        0 (>L:WINDOW CONTROL LHR, bool)
                        0 (>L:WINDOW CONTROL RHR, bool)
                    }
                    }
         </Value>
      </Select>
   </Element>


Note above, all the spacings, gaps, etc.

Commands have the numbers in front, (except for data/range which is spelled rng)

Data has the info behind the string, and will have symbols in the back of the string.

When writing a command string (telling something to do something) you put a > or &gt; symbol set 'inside' the string () and a command of 1, 0, etc in front of its () and you will be good to go.

Command strings are different then data strings, so be sure you are looking for the right things to make things work. One letter off and it doesn't work. Use the wrong command and it doesn't work.
 
Last edited:
Hi lionheart,

I appreciate you taking time out to "break it down" for me. I try to take time and try out everything folks tell me, but as you can see, things have "wandered off course!" a bit. smile

I'm trying to get my L:var animation to trigger, not by direct command from a gauge, but when the the left engine starter (A:GENERAL ENG STARTER:1, bool), AND the fuel mixture for that engine (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt; is set for that engine to start.

In other words, the animation should start when that engine begins the start up process.

I will redo the code given the insight you've shared and report back here in a bit.

Thanks again!
 
Ok, quick question lionheart, I just ran into something after looking at your examples and other default code in the modeldef.xml. It order to "establish" the L:var as the primary variable to execute based on the state of the other variables, how would that be written? From what I gather, shouldn't it go something like this: (Please correct me if I'm wrong)

<Code>
(L:PROP0_STARTUP, bool) Primary var
if{
(A:GENERAL ENG GENERATOR SWITCH:1, bool) 1==
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; State of the A: var's
and
}
(L:PROP0_STARTUP, bool) 500 * If the generator switch is on, and the mixture is set to 50% or greater, then run this L:var animation at 500 frames
</Code>
 
Ok, let's see.

You say you want your animation to start when certain conditions are met. It means you don't actually need a variable for that, only a value to play the animation with. Then, there's no reason for (L:PROP0_STARTUP, bool).

Despite lionheart's good intentions with his examples, they are not correct. So let's start by the basics.

-Variables which the animation depends on:

(A:GENERAL ENG STARTER:1, bool) 1 ==
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt;

You can handle the animation just by writing:

Code:
<Code>
  (A:GENERAL ENG STARTER:1, bool) 
  (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; and
  if{ 500 }
  els{ 0 }
</Code>

Now, if you still want to use (L:PROP0_STARTUP,bool), you first need to give a value to this var, so my first example applies correctly here, unless you want to update the var via a mouse click in other part of the code:

Code:
<Code>
  (A:GENERAL ENG STARTER:1, bool) 
  (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &gt; and
  if{ 1 (>L:PROP0_STARTUP, bool) }
  els{ 0 (>L:PROP0_STARTUP, bool) }
  (L:PROP0_STARTUP, bool) 500 *
</Code>

Also you don't need (A:GENERAL ENG GENERATOR SWITCH:1, bool) in the formula as it is not related to the starting process.

If none of these examples work, then the problem is in the part of your code that I don't know -yet.

Hope this helps a bit more than my former posts :)

Tom
 
Hi Bill,

You are giving him examples of 2D gauge programming, but he is asking about modeldef entries. Both XML, but different formats and programming logic.

bwest0131,

This is a re-hash of other posts, but I'll take a stab too...

The thing to remember about modeldef entries is that the value obtained from the Code section within the Animation section is then used as the current keyframe value for the animation (if any). So you not only have to provide the correct programming logic, but also keyframe animate the part with that logic in mind (I usually do it the other way - keyframe animate the part, and then figure out the modeldef programming to fit, but it should be a cooperative approach instead).

So, let's look at your code:
Code:
<Code>
(L:PROP0_STARTUP, bool) 500 * 
if{ 
(A:GENERAL ENG STARTER:1, bool) 1
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt; 
AND 
}
els{ 0 }
</Code>

What keyframe value will you generate?

Let's assume that your test is:

(A:GENERAL ENG STARTER:1, bool) 1
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt;
AND

And if it's true you want the keyframe value to be:

(L:PROP0_STARTUP, bool) 500 *

If so you have these backwards, and the code should read:

(A:GENERAL ENG STARTER:1, bool) 1
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt;
AND
if{
(L:PROP0_STARTUP, bool) 500 *
}
els{ 0 }

I'll assume this is what you want. Then we have the first line in this code:

(A:GENERAL ENG STARTER:1, bool) 1

This tells FS to put the result of the engine starter variable on the stack, and then put a 1 on the stack. If you wanted to test if the variable equals one, then you should have written:

(A:GENERAL ENG STARTER:1, bool) 1 ==

But this is not really necessary, since all you want is a TRUE result if the starter has activated, and you can do that with:

(A:GENERAL ENG STARTER:1, bool)

This will return a FALSE (0) if not true, and a TRUE (1) if it has been activated.

Then you state:

(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt;

which means you want this startup keyframe to have a value when the mixture is less than 50%. OK, fine. And we need to change AND to and, as mentioned above.

Finally, if both of these things are true (the starter has activated and the mixture is less than 50%), then the value of the keyframe will be:

(L:PROP0_STARTUP, bool) 500 *

the value of which will depend on the other code that controls the value of this variable. For example, if it varies between 0 and 1, then the keyframe value will vary between keyframe 0 and keyframe 500.

BTW, it is better to name it something like (L:Prop0_startup, enum) or (L:Prop0_startup, number) since (as Bill says) bool variables can only have a value of 1 or 0. FS doesn't care what you use as the units of L: variables, for the most part, but it does help your mental clarity. :)

So the final code I come up with is:

Code:
<Code>
(A:GENERAL ENG STARTER:1, bool)
(A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 50 &lt; 
and
if{ 
(L:PROP0_STARTUP, bool) 500 * 
}
els{ 0 }
</Code>

which could be further edited, based on my other comments above.

Hope this helps,
 
Hi tgibson,

That's what I came up with and posted (minus the els{ 0 } statement) prior to your reply, thanks for the confirmation!

So far, the L:var startup animation works as desired when starting the engines (turboprops) by default FSX key commands:

Code:
<PartInfo>
      <Name>prop0_startup</Name>              
        <AnimLength>600</AnimLength>
         <Animation>
         <Parameter>
          <Code>
            (L:PROP0_STARTUP, bool) 
          if{
            (A:GENERAL ENG STARTER:1, bool) 1 == 
            (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 40 &lt;            
            (A:PROP MAX RPM PERCENT:1, percent) 6 &lt; 
            and and
             }             
           1 (&gt;L:PROP0_STARTUP, bool) 600 *  
           </Code>
        <Lag>50</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Left Prop Start</TooltipText>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode> 
           1 (&gt;A:GENERAL ENG STARTER:1, bool)
           1 (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 40 &lt;             
           1 (A:PROP MAX RPM PERCENT:1, percent) 6 &lt;                          
      </CallbackCode>
    </MouseRect>
 </PartInfo>


With the visability code:

Code:
<PartInfo>
        <Name>prop0_startup_vis</Name>
        <AnimLength>600</AnimLength>
        <Visibility>
            <Parameter>
        	<Code>                  
                  (A:GENERAL ENG STARTER:1, bool)  1 ==                    
        	  (A:GENERAL ENG MIXTURE LEVER POSITION:1, percent) 40 &lt; &amp;&amp;
        	  (A:PROP MAX RPM PERCENT:1, percent) 6.25 &lt; &amp;&amp;
        	  if{ 1 } els{ 0 }
       	       </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

Now I just need to refine all of the animations, the "shutdown" process and match it up to work with any third party "engine start up" gauges users may install and use and I'm in business!!

Thanks guys for the productive imput and feedback!!! smile.
Hopefully this will save somebody else out there time and frustration trying to accomplish the same thing I was shooting for!!!

Till next time.................(probably soon!!! LOL)

:)
 
Please, do not be discouraged by any of this or take it the wrong way, as we all truly do want to help you to understand!

None of what you've just posted make any sense whatsoever, I'm sorry to say. There are so many logical and syntax errors it's hard to keep track of them all, so let's just examine some of the "rules" once more in an attempt to grasp the basics.

1. Basic conditonal logic structure in XML...

Code:
(conditions) if{ (>do something) } els{ (>do something different) }

Please note that the "if{" applies to the (conditions), not to what is inbetween the curly braces! The "logic" is reverse-Polish notation, meaning what follows anything is applied to whatever comes before it in the chain...

So, evaluating the above into "english" we have:
if (conditions) are TRUE then (>do something)
else (>do something different)

2. A:variables

All (A:variable,units) as used in XML are read only. Simply put, you cannot assign a value to them, so something like 1 (&gt;A:GENERAL ENG STARTER:1, bool) is completely meaningless.

3. K:events

These are the commands we can give to FS via an XML script. Most (A:vars) have a corresponding (>K:event). Check the SDK's list to determine which (>K:event) to use. I've purposely included the ">" (assign operator) with the K: simply because without it the command is incomplete and meaningless.

Most (>K:events) are "binary toggles"; do them once to activate, do them again to deactivate, for example:
Code:
(>K:STROBES_TOGGLE) will set the (A:LIGHT STROBE,bool) variable to 1
(>K:STROBES_TOGGLE) again, will set the (A:LIGHT STROBE,bool) variable to 0

Those (>K:events) with the suffix _SET in their name require some number to be sent to them before they will do anything. The range of acceptable number values are listed in the SDK. For example:
Code:
8150 (>K:THROTTLE_SET)
will set (all) throttles to ~50%

4. L:vars

Custom (L:vars) are unique in one way; we can both "read" them and "assign a value" to them.

All (L:vars) are initialized to a value of zero (0) when they are created at aircraft load. They will remain zero until we give them a value using the ">" function operator:

40 (>L:MyVariable,number)

The above will assign the number "40" to that custom variable.

Now all that said, the only reason that the prop is actually doing anything at all is purely by accident:

Code:
1 (&gt;L:PROP0_STARTUP, bool) 600 *
Evaluating the above we are assigning the number "1" to the L:variable, then multiplying the result by 600...

We could have simply written
Code:
600
and achieved the same result!

To be honest, you are really "overthinking" this... ;)
 
Last edited:
Hi n4gix,

I've read through and appreciate your explaination of the "basics" of the whole thing and will probably refer back to this thread at a later date. The code I posted, the stuff you say "doesn't make any sense at all" works, and at the moment, that's all that really matters!!!!! smile

Don't get me wrong, in the near future, when I've got more time, I'll go back over the information / comments you've posted and attempt to "see" things the way you are looking at them and figure out what I can do to get the code to "make sense" and if I'm lucky, maybe even "logical" (LOL!!), but for now, everthing I've posted "works" and to be quite honest, that's all I really care about!!!

Thanks again though for taking time out of your schedule to break things down for me, I'll most definately put the "info" to good use!!!! smile

Take care!
 
My apologies. I thought it was for invisible gauges. arrgh.

Thanks everyone for helping him out with good information.
 
You're welcome. :)

While your part may "work", your next one may not if still coding things incorrectly. Always best to understand how things should really work.
 
Status
Not open for further replies.
Back
Top