FSXA [Solved]Gauge to ModelDef, any XML changes required?

Kekelekou

Resource contributor
#1
Hello,

I am working on an animated firefighter signaling to the airtanker pilot the required actions at refill station (to be used along FireFighterX).
I had added the animation code to a XML gauge so that debugging was much easier. The codes is now working like a charm.
But I would like to directly inject the code into the MDL file, so that no panel/gauge fiddling is required from the end-user.
So I have just updated the anim code in the ModelDef to include the whole code as given below. But no joy ingame.

I have heard about XML format changes between gauges and ModelDef, could this be the cause of the animation failure ingame?

Any help appreciated.

Have a nice evening.

Code:
<?xml version="1.0" encoding="utf-8"?>

<ModelInfo>

  <Animation name="Peli_Guide_anim" guid="03351903-AF90-41fa-9406-8098038A0823" length="1000" type="Sim" typeParam2="Peli_Guide_anim" typeParam="AutoPlay" />

  <PartInfo>

    <Name>Peli_Guide_anim</Name>

    <AnimLength>1000</AnimLength>

    <Animation>

      <Parameter>

        <Code>



(L:RefillStation_Distance, number) 10 - 0 max (&gt; L:Peli_DistToZone, number)




(L:Peli_CurrentStatus, enum) 0 !=

(L:Peli_CurrentStatus, enum) 0 ==

(L:RefillStation_Status, number) 1 == &amp;&amp;

||

if{



    (L:Peli_Timer, number) 90 &gt;=

    if{

        (L:Peli_CurrentStatus, enum) (L:RefillStation_Status, number) !=

        if{

            (L:Peli_Timer, enum) 99 ==

            if{

                (L:Peli_CurrentStatus, enum) 4 ==

                (L:Peli_CurrentStatus, enum) 5 ==

                ||

                (L:RefillStation_Status, number) 0 ==

                &amp;&amp;

                if{

                    9 (&gt; L:Peli_CurrentStatus, enum)

                    0 (&gt; L:Peli_LoopStart, number)

                    0 (&gt; L:Peli_IsLoop, bool)

                    0 (&gt; L:Peli_Timer, number)

                }

              

                (L:Peli_CurrentStatus, enum) 9 ==

                (L:Peli_DistToZone, number) 150 &gt;

                (A:Sim On Ground, bool) ! ||

                &amp;&amp;

                if{

                    0 (&gt; L:Peli_CurrentStatus, enum)

                    30 (&gt; L:Peli_LoopStart, number)

                    1 (&gt; L:Peli_IsLoop, bool)

                    1 (&gt; L:Peli_Timer, number)

                }

              

                (L:RefillStation_Status, number) 1 ==

                if{

                    1 (&gt; L:Peli_CurrentStatus, enum)

                    80 (&gt; L:Peli_LoopStart, number)

                    0 (&gt; L:Peli_IsLoop, bool)

                    80 (&gt; L:Peli_Timer, number)

                }

              

                (L:RefillStation_Status, number) 2 ==

                (L:RefillStation_Status, number) 3 == ||

                (L:RefillStation_Status, number) 4 == ||

                (L:RefillStation_Status, number) 5 == ||

                if{

                    (L:RefillStation_Status, number) (&gt; L:Peli_CurrentStatus, enum)

                    70 (&gt; L:Peli_LoopStart, number)

                    1 (&gt; L:Peli_IsLoop, bool)

                    60 (&gt; L:Peli_Timer, number)

                }


                (L:RefillStation_Status, number) 6 ==

                (L:RefillStation_Status, number) 7 == ||

                if{

                    (L:RefillStation_Status, number) (&gt; L:Peli_CurrentStatus, enum)

                    0 (&gt; L:Peli_LoopStart, number)

                    0 (&gt; L:Peli_IsLoop, bool)

                    60 (&gt; L:Peli_Timer, number)

                }


                (L:RefillStation_Status, number) 8 ==

                if{

                    8 (&gt; L:Peli_CurrentStatus, enum)

                    0 (&gt; L:Peli_LoopStart, number)

                    0 (&gt; L:Peli_IsLoop, bool)

                    90 (&gt; L:Peli_Timer, number)

                }


            }

      

            els{

                (L:Peli_Timer, number) 1.0 + 99 min (&gt; L:Peli_Timer, number)

            }

      

        }

      

        els{

            (L:Peli_IsLoop, bool)

            if{

                (L:Peli_LoopStart, number) (&gt; L:Peli_Timer, number)

            }

        } 

  


  

    }

  

    els{

        (L:Peli_Timer, number) 1.0 + 90 min (&gt; L:Peli_Timer, number)

    }


}


      

els{

  

    (L:Peli_DistToZone, number) 300 &lt;

    if{

      

        (L:Peli_DistToZone, number) 15 &lt;

        if{

            90

          

            99 90 -

            15 (L:Peli_DistToZone, number) - 0 max

            15 /

            *

          

            +

            (&gt; L:Peli_Timer, number)

        }

      

        els{

            (L:Peli_Timer, number) 90 &gt;=

            if{

                30 (&gt; L:Peli_Timer, number)

            }

            els{

                (L:Peli_Timer, number) 1.0 + 90 min (&gt; L:Peli_Timer, number)

            }

        }

    }

  

    els{

        25 0 300 5 + (L:Peli_DistToZone, number) - max +

        (&gt; L:Peli_Timer, number)

    }

  

}



100 (L:Peli_CurrentStatus, number) *

(L:Peli_Timer, number) +

                </Code>

      </Parameter>

    </Animation>

  </PartInfo>

</ModelInfo>
In the working "gauge" version, the modeldef featured only the last "100 (L:peli_CurrentStatus, number) * (L:peli_Timer, number) +" bit. All the rest was included in a panel gauge.

19/03/2019 Edit : The issue is related to the fact that this code is not run by the user aircraft's MDL, but by an AI ground vehicle.
 
Last edited:
#2
If that code you supplied is a direct copy from your ModelDef then something drastic happened in the formatting, mainly the "& gt ;" when writing to a L:Var.
Below is a cleaned up code set, nothing in the logic was changed. Formatted to keep track of the if/else's.
Just don't know, maybe try the code below.
XML:
<Animation name="Peli_Guide_anim" guid="03351903-AF90-41fa-9406-8098038A0823" length="1000" type="Sim" typeParam2="Peli_Guide_anim" typeParam="AutoPlay" />

<PartInfo>
    <Name>Peli_Guide_anim</Name>
    <AnimLength>1000</AnimLength>
    <Animation>
        <Parameter>
            <Code>
                (L:RefillStation_Distance, number) 10 - 0 max (>L:Peli_DistToZone, number)

                    (L:Peli_CurrentStatus, enum) 0 != (L:Peli_CurrentStatus, enum) 0 == (L:RefillStation_Status, number) 1 == and ||  if{
                        (L:Peli_Timer, number) 90 &gt;= if{
                            (L:Peli_CurrentStatus, enum) (L:RefillStation_Status, number) != if{ 
                                (L:Peli_Timer, enum) 99 == if{
                                    (L:Peli_CurrentStatus, enum) 4 == (L:Peli_CurrentStatus, enum) 5 == || (L:RefillStation_Status, number) 0 == and if{
                                        9 (>L:Peli_CurrentStatus, enum) 0 (>L:Peli_LoopStart, number) 0 (>L:Peli_IsLoop, bool) 0 (>L:Peli_Timer, number) 
                                    }
                                    (L:Peli_CurrentStatus, enum) 9 == (L:Peli_DistToZone, number) 150 &gt; (A:Sim On Ground, bool) ! || and if{ 
                                        0 (>L:Peli_CurrentStatus, enum) 30 (>L:Peli_LoopStart, number) 1 (>L:Peli_IsLoop, bool) 1 (>L:Peli_Timer, number) 
                                    }
                                    (L:RefillStation_Status, number) 1 == if{ 
                                        1 (>L:Peli_CurrentStatus, enum) 80 (>L:Peli_LoopStart, number) 0 (>L:Peli_IsLoop, bool) 80 (>L:Peli_Timer, number) 
                                    }
                                    (L:RefillStation_Status, number) 2 == (L:RefillStation_Status, number) 3 == || (L:RefillStation_Status, number) 4 == || (L:RefillStation_Status, number) 5 == || if{
                                        (L:RefillStation_Status, number) (>L:Peli_CurrentStatus, enum) 70 (>L:Peli_LoopStart, number) 1 (>L:Peli_IsLoop, bool) 60 (>L:Peli_Timer, number) 
                                    }
                                    (L:RefillStation_Status, number) 6 == (L:RefillStation_Status, number) 7 == || if{
                                        (L:RefillStation_Status, number) (>L:Peli_CurrentStatus, enum) 0 (>L:Peli_LoopStart, number) 0 (>L:Peli_IsLoop, bool) 60 (>L:Peli_Timer, number) 
                                    }
                                    (L:RefillStation_Status, number) 8 == if{ 
                                        8 (>L:Peli_CurrentStatus, enum) 0 (>L:Peli_LoopStart, number) 0 (>L:Peli_IsLoop, bool) 90 (>L:Peli_Timer, number) 
                                    }
                                } els{
                                    (L:Peli_Timer, number) 1.0 + 99 min (>L:Peli_Timer, number)
                                }
                            } els{ 
                                (L:Peli_IsLoop, bool) if{ 
                                    (L:Peli_LoopStart, number) (>L:Peli_Timer, number)
                                }
                            }  
                        } els{ 
                            (L:Peli_Timer, number) 1.0 + 90 min (>L:Peli_Timer, number)
                        }
                    } els{ 
                        (L:Peli_DistToZone, number) 300 &lt; if{ 
                            (L:Peli_DistToZone, number) 15 &lt; if{ 
                                90 99 90 - 15 (L:Peli_DistToZone, number) - 0 max 15 / * + (>L:Peli_Timer, number) 
                            } els{ 
                                (L:Peli_Timer, number) 90 &gt;= if{
                                    30 (>L:Peli_Timer, number)
                                } els{ 
                                    (L:Peli_Timer, number) 1.0 + 90 min (>L:Peli_Timer, number) 
                                }
                            }
                        } els{ 
                            25 0 300 5 + (L:Peli_DistToZone, number) - max + (>L:Peli_Timer, number) 
                        }
                    }

                100 (L:Peli_CurrentStatus, number) * (L:Peli_Timer, number) +
            </Code>
        </Parameter>
    </Animation>
</PartInfo>
 

Kekelekou

Resource contributor
#3
Hello Roman,

Thanks for helping!
I have got used to typing "&gt;" instead of ">" (and "lt;" for "<") in my gauges, but it might not be necessary to do so.
I'll test and report with your reformatted code.
Thanks again.
 
Last edited:
#4
@Kekelekou both &gt; and > are accepted in modeldef.xml. There is a syntax problem that can be seen below (direct comparison):

As you can see in the examples, you have a whitespace between &gt; and the L:var, which breaks the syntax rules.

XML:
(&gt; L:Peli_DistToZone, number)
(&gt;L:Peli_DistToZone, number)
Alternatively:

XML:
(&gt; L:Peli_DistToZone, number)
(>L:Peli_DistToZone, number)
 

Kekelekou

Resource contributor
#6
Thx all for your kind input.
I must say I am puzzled because I am pretty sure the gauge code features the space in the « &gt; L: », but it works fine. Maybe that’s the while point between gauge and modeldef syntaxes?
I’ll test that too.
 

n4gix

Resource contributor
#8
Thx all for your kind input.
I must say I am puzzled because I am pretty sure the gauge code features the space in the « &gt; L: », but it works fine. Maybe that’s the while point between gauge and modeldef syntaxes?
I’ll test that too.
If your sample code was not contained in a CODE box format, then the added space was inserted to prevent the board software from treating it as a smilie. The space will prevent the scripted variable from working properly. The is undoubtedly something else wrong with your script.
 

Kekelekou

Resource contributor
#9
Getting back at this...

I gave another shot today, but I am still experiencing weird things:
- the code works fine when in a gauge
- when the code is "modeldefed" into the MDL, it does not run at all (all Lvars are stuck to 0), but I can still choose the KF by setting Peli_CurrentStatus and Peli_Timer with LINDA. This means that the sim sees what's inside the code section.
I concluded from that the main if/els sections may be faulty :
- I tried deleting everything in the main if{} section, no joy
- I tried deleting everything in the main els{} section, no joy neither

I am puzzled to say the least...
 

Kekelekou

Resource contributor
#10
Good lord!

Even a anim code as simple as this one does not work : No incrementation of Peli_Timer when its value is brought above 100 with LINDA. What the heck is going on?
Code:
<?xml version="1.0" encoding="utf-8"?>
<ModelInfo>
  <Animation name="Pelicandrome_Guidage_anim1" guid="994959c3-90d4-4f94-b229-8ef5ba9d5c91" typeParam2="Pelicandrome_Guidage_anim1" length="999" type="Sim" typeParam="AutoPlay" />
  <PartInfo>
    <Name>Pelicandrome_Guidage_anim1</Name>
    <AnimLength>999</AnimLength>
    <Animation>
      <Parameter>
        <Code>
(L:Peli_Timer, number) 100 &gt;=
            if{
                (L:Peli_Timer, number) 1.0 + (&gt; L:Peli_Timer, number)
            }

100 (L:Peli_CurrentStatus, number) *
(L:Peli_Timer, number) +
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>
</ModelInfo>
Just to check if "if{}" code is run (or even read), I have just tested this code. Which is working as expected.

Code:
<?xml version="1.0" encoding="utf-8"?>
<ModelInfo>
  <Animation name="Pe_Guidage_anim" guid="994959c3-90d4-4f94-b229-8ef5ba9d5c90" length="1000" type="Sim" typeParam2="Pe_Guidage_anim" typeParam="AutoPlay" />
  <PartInfo>
    <Name>Pe_Guidage_anim</Name>
    <AnimLength>1000</AnimLength>
    <Animation>
      <Parameter>
        <Code>
(L:Peli_Timer, number) 100 &lt;
if{
    (L:Peli_Timer, number) 50 &lt;
    if{
        190
    }

    els{
        932
    }
}

els{
    580
}
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>
But what follows won't work :

Code:
 <Animation name="Pelicandrome_Guidage_anim1" guid="994959c3-90d4-4f94-b229-8ef5ba9d5c91" length="1000" type="Sim" typeParam2="Pelicandrome_Guidage_anim1" typeParam="AutoPlay" />
  <PartInfo>
    <Name>Pelicandrome_Guidage_anim1</Name>
    <AnimLength>1000</AnimLength>
    <Animation>
      <Parameter>
        <Code>
(L:Peli_Timer, number) 100 &gt;=
            if{
                (L:Peli_CurrentStatus, number) 1.0 + (&gt; L:Peli_CurrentStatus, number)
            }

100 (L:Peli_CurrentStatus, number) *
(L:Peli_Timer, number) +
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>
So evaluations seem to work fine, while calculations or value assignments won't.
Has anyone ever face such a "no calculations or value assignments within a modeldef if{} section" limitation? Would be weird though
 
Last edited:

n4gix

Resource contributor
#11
Try this math instead:
(L:Peli_CurrentStatus, number) ++ (&gt;L:Peli_CurrentStatus, number)

Hint 1: if you want to increment by one, ++ will work just as well as 1 +
Hint 2: your "math" failed because you have a space between (&gt; and L:....
Hint 3: I prefer using the > symbol exclusively for XML assignment functions: (>L:...)
 

Kekelekou

Resource contributor
#12
Thank you Bill for your input, once again.
Hint 1 : I wrote 1.0 + because the value defines the animation speed. I find it more explicit with 1.0 rather than with ++.
Hint 2 : I am pretty sure I tested with no space, but I'll double-check tonight. Won't harm. By the way, if this is the root-cause of the failure, this means that this is a discrepency between ModelDef XML and gauge XML : the code posted in my first comment runs smoothly from a gauge (and with space between &gt; and L:var)
Hint 3 : So far, I have wanted to keep consistency with my code by always typing &gt; and &lt;. But if it can fix my issue, I'll change my point of view.
 

n4gix

Resource contributor
#13
Hint 3: In this sole case where the symbol > works, I use it strictly for my own clarity. The fact that it's only one character rather than four is yet another reason.

In this one instance there is no functional difference between > and &gt; :teacher:
 

Kekelekou

Resource contributor
#14
No joy with neither

Code:
<Code>
(L:Peli_Timer, number) 100 &gt;=
            if{
                4 (>L:Peli_CurrentStatus, number)
            }

100 (L:Peli_CurrentStatus, number) *
(L:Peli_Timer, number) +
        </Code>
nor

Code:
<Code>
(L:Peli_Timer, number) ++ (>L:Peli_Timer, number)

(L:Peli_Timer, number)
        </Code>
nor

Code:
<Animation>
      <Parameter>
        <Code>
95 (>L:Peli_Timer, number)

(L:Peli_Timer, number)
        </Code>
      </Parameter>
    </Animation>

This is getting ridiculous... o_O

Edit : By "doesn't work" I mean Peli_Timer value remains at 0 whatever the code should force it to. But when altered with Linda the supposed KF is reached indeed.
 
Last edited:

n4gix

Resource contributor
#15
You know, I've actually only been looking for syntax errors. I finally occurred to me to examine the logic. In the following example, you are looking for a condition of (L:Peli_Timer, number 100 &gt;... How and where is this condition being reached? Nowhere that I can see.

What are these two lines supposed to accomplish?
100 (L:Peli_CurrentStatus, number) *
(L:Peli_Timer, number) +


Code:
(L:Peli_Timer, number) 100 &gt;=
            if{
                (L:Peli_CurrentStatus, number) 1.0 + (&gt; L:Peli_CurrentStatus, number)
            }

100 (L:Peli_CurrentStatus, number) *
(L:Peli_Timer, number) +
 

Kekelekou

Resource contributor
#16
I set the value of
Code:
L:Peli_Timer
through LINDA. So that I can check if changing its value ends up in
Code:
L:Peli_CurrentStatus
changing too.

The last two lines are the ones that set the KF depending on the status of the Lvars. I suspected first that I couldn't have a Lvar assignement AND a calculation at the same time. I have kept the lines but they are not essential in the test code.
 
#17
I concur with Fr. Bill.. Looking at the original code from above, nowhere in it does "peli_Timer" gets assigned any value before the 2nd if{ ..

XML:
<Animation name="Peli_Guide_anim" guid="03351903-AF90-41fa-9406-8098038A0823" length="1000" type="Sim" typeParam2="Peli_Guide_anim" typeParam="AutoPlay" />

<PartInfo>
    <Name>Peli_Guide_anim</Name>
    <AnimLength>1000</AnimLength>
    <Animation>
        <Parameter>
            <Code>
                (L:RefillStation_Distance, number) 10 - 0 max (>L:Peli_DistToZone, number)

                    (L:Peli_CurrentStatus, enum) 0 != (L:Peli_CurrentStatus, enum) 0 == (L:RefillStation_Status, number) 1 == and ||  if{
                        (L:Peli_Timer, number) 90 &gt;= if{

<!-- EVERYTHING IN THIS AREA DOESN'T MATTER  - L:Peli_Timer never gets above 0. -->

                         }
                    }

                100 (L:Peli_CurrentStatus, number) * (L:Peli_Timer, number) +
            </Code>
        </Parameter>
    </Animation>
</PartInfo>
 
Last edited:

Kekelekou

Resource contributor
#18
Thanks for posting.
I am pretty confident that the original code works as expected because I tested it as follows : all the code in a gauge except this last bit in the modeldef animation:


Code:
100 (L:peli_CurrentStatus, number) *
(L:peli_Timer, number) +
And this works absolutely fine!


That’s why I don’t understand why the same darn code won’t work when injected from the modeldef!
 
#19
Be aware of what your code accomplishes, namely, as far as I can see:
Code:
timer      0-99     100   101   102 ...  107   108
status     0        1     2     3   ...  8     9
result    0-100    200   301   402 ...  907    unpredictable
Your timer can only run from 0 to 107 (really?); your animation will be active even if timer is less than 100 (really?) ... many other questions, including why make it so trap-prone in the first place. Of course you could assign that last calculation to a variable and read it out together with current time and status values, better than relying on anything else.
 

Kekelekou

Resource contributor
#20
Thanks for joining mjahn!

Just to make things clear : The only real code that is supposed to run the anim is the one posted in my #1 comment. This code runs flawless if used in a XML gauge and the modeldef featuring only the "100 (L: peli_CurrentStatus, number) * (L: peli_Timer, number) +" bit.

All others are TEST codes supposed to help me finding the bug. They are not supposed to work in a meaningful way. I just wanted to check if specific features work indeed (lvar assignements) or and the entrance in a if{} section (by setting values with LINDA).
 
Top