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

FSXA Help for animation code in modeldef.xml

Messages
47
Country
us-california
Hi Simmer Experts,
I have made a dummy Cab Heat lever that has no purpose except to display animation for 0 to 100 frames. There is no Cabin Heat function and that is why I am making the dummy. The attached code will not work in the modeldef.xml which will not load with this code installed. I have it located down to the callback code, I ask what is wrong in that area?

Code:
   <Animation name="lever_cab_heat" guid="9E5346B0-87EE-462d-A2C4-539A00DE252D" length="100" type="Sim" typeParam2="lever_cab_heat" typeParam="AutoPlay" />
   
 <!--P2004B bravo items-->

  <PartInfo>
    <Name>lever_cab_heat</Name>
       <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>L:Cab_Heat_Adjust</Variable>
                    <Units>number</Units>
                    <Scale>1</Scale>
                </Sim>
            </Parameter>
        </Animation>
  <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle+RightSingle</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmi 0 == if{ (L:Cab_Heat_Adjust, number) 1 - s0 10 > if{ 10 } els{ l0 } (>L:Cab_Heat_Adjust, number) (L:Cab_Heat_Adjust, number) 1 < if{ 0 (>L:Cab_Heat_Adjust,number) }
        (M:Event) 'RightSingle' scmi 0 == if{ (L:Cab_Heat_Adjust, number) 1 + s0 10 > if{ 10 } els{ l0 } (>L:Cab_Heat_Adjust, number) (L:Cab_Heat_Adjust, number) 1 < if{ 0 (>L:Cab_Heat_Adjust,number) }
      </CallbackCode>
      <TooltipID></TooltipID>
  </MouseRect>
  </PartInfo>
 <!--end P2004B Bravo items-->

Thanks in advance for any help rendered.

Richie35
 
Way too "complicated" and incorrect:
Code:
      <CallbackCode>
        (M:Event) 'LeftSingle' scmi 0 == if{ (L:Cab_Heat_Adjust, number) 1 - s0 10 > if{ 10 } els{ l0 } (>L:Cab_Heat_Adjust, number) (L:Cab_Heat_Adjust, number) 1 < if{ 0 (>L:Cab_Heat_Adjust,number) }
        (M:Event) 'RightSingle' scmi 0 == if{ (L:Cab_Heat_Adjust, number) 1 + s0 10 > if{ 10 } els{ l0 } (>L:Cab_Heat_Adjust, number) (L:Cab_Heat_Adjust, number) 1 < if{ 0 (>L:Cab_Heat_Adjust,number) }
      </CallbackCode>

Do it the "easy way" instead:

Code:
<CallbackCode>
  (M:Event) 'LeftSingle' scmp 0 ==
       if{ (L:Cab_Heat_Adjust, number) -- 0 max (>L:Cab_Heat_Adjust, number) }
  (M:Event) 'RightSingle' scmp 0 ==
       if{ (L:Cab_Heat_Adjust, number) ++ 100 min (>L:Cab_Heat_Adjust, number) }
</CallbackCode>
 
Way too "complicated" and incorrect:
Code:
      <CallbackCode>
        (M:Event) 'LeftSingle' scmi 0 == if{ (L:Cab_Heat_Adjust, number) 1 - s0 10 > if{ 10 } els{ l0 } (>L:Cab_Heat_Adjust, number) (L:Cab_Heat_Adjust, number) 1 < if{ 0 (>L:Cab_Heat_Adjust,number) }
        (M:Event) 'RightSingle' scmi 0 == if{ (L:Cab_Heat_Adjust, number) 1 + s0 10 > if{ 10 } els{ l0 } (>L:Cab_Heat_Adjust, number) (L:Cab_Heat_Adjust, number) 1 < if{ 0 (>L:Cab_Heat_Adjust,number) }
      </CallbackCode>

Do it the "easy way" instead:

Code:
<CallbackCode>
  (M:Event) 'LeftSingle' scmp 0 ==
       if{ (L:Cab_Heat_Adjust, number) -- 0 max (>L:Cab_Heat_Adjust, number) }
  (M:Event) 'RightSingle' scmp 0 ==
       if{ (L:Cab_Heat_Adjust, number) ++ 100 min (>L:Cab_Heat_Adjust, number) }
</CallbackCode>

Thanks for the response but what I do not understand is that the code I have displayed works in the gauge for 2d panel but will not work with the animation modeldef.xml. Could you please explain?

Richie

update/
the animation is still not working although the Cab_Heat_adjust,number is adjusting just the animation is not responding.
Another problem has just arrived. The door control will only work on Door_0 and I have two doors. For some reason it is ignaoring Door_1, Door_2 and Door_3. Both doors work when assigned to Door_0 only. The aircraft .cfg file has two exits listed and exit.0 and exit.1. Note that this is working on other aircraft and previously worked on this model. I tried reverting back to an earlier version of modeldef.xml but no luck there so I think that is not the cause. Any ideas?

richie

Update:
I was able to get the animation working correctly by using the revised code but I cannot get the ToolID to work. Can I only use the tips in the SDK or is ther a way to insert my own reference text?
I am still having the issue with the left and right side doors only responding to Door_0 animation.

Thanks for your time and advice.

Richie

Code:
 <!--P2004B bravo items-->

  <PartInfo>
    <Name>lever_cab_heat</Name>
       <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
              <Code>(L:Cab_Heat_Adjust, number) 
              </Code>
            </Parameter>
        </Animation>
  <MouseRect>
      <Cursor>Hand</Cursor>
      <ToolTipID>"Cab Heat (%((L:Cab_Heat_Adjust,enum) 0 >)%{if}on%{else}off%{end})"</ToolTipID> 
      <MouseFlags>LeftSingle+RightSingle</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 == if{ (L:Cab_Heat_Adjust, number) 10 - 0 max (>L:Cab_Heat_Adjust, number) }
        (M:Event) 'RightSingle' scmp 0 == if{ (L:Cab_Heat_Adjust, number) 10 + 100 min (>L:Cab_Heat_Adjust, number) }
      </CallbackCode>
  </MouseRect>
  </PartInfo>
 
<!--end P2004B Bravo items-->
 
Last edited:
Use <TooltipText> instead:

Code:
<TooltipText>
     Cab Heat: %((L:Cab_Heat_Adjust,enum) 0 >)%{if}on%{else}off%{end}
</TooltipText>
 
Use <TooltipText> instead:

Code:
<TooltipText>
     Cab Heat: %((L:Cab_Heat_Adjust,enum) 0 >)%{if}on%{else}off%{end}
</TooltipText>

Thanks for the reply. I am still having a problem with the side doors on my model only in that they will only respond to Shift+E. The other Dhift+e+1 etc have no effect. To get door 2 to operate it has to have Door_0 assigned. I cannot see what is causing this problem. All the other aircraft including the defaults and my other models work fine.

Richie
 
Is your [exits] section in the aircraft.cfg file correct? It needs to reflect the number of exits you have in your model.
 
Yes, My aircraft.cfg is set to this config.
[exits]
number_of_exits = 2
exit.0 = 0.4, -20.4767, 23.1396, -3.6936, 0 //openclose rate percent per second, longitudinal, lateral, vertical positions from datum (feet), type (0=Main 1=Cargo 2=Emergency)
exit.1 = 0.4, 20.44767, 23.1396, -3.6912, 0 //openclose rate percent per second, longitudinal, lateral, vertical positions from datum (feet), type (0=Main 1=Cargo 2=Emergency)
It worked previously but the strange thing is it only responds to Shift+E and when the door has been opened, if I enter 1 nothing happens only on the Shift+E entry. So at the present time I have both doors on Door_0. I even tried using Door_1 animation and no movement. I am baffled.
What I think I will do is make a box and have the left and right sides set for the door animation and see what the response shows.
Thanks for the response.

Richie
 
To open door_1 (the second door!), you need to combine two commands as shown in the example below: toggle the exit, followed by a select command:

Code:
  <PartInfo>
    <Name>door_1</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Sim>
          <Variable>EXIT OPEN:1</Variable>
          <Units>percent</Units>
        </Sim>
      </Parameter>
    </Animation>
    <MouseRect>
      <TooltipText>Open Pilot Window</TooltipText>
      <Cursor>Hand</Cursor>
      <CallbackCode>
        (>K:TOGGLE_AIRCRAFT_EXIT,bool)
        (>K:SELECT_2,bool)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
To open door_1 (the second door!), you need to combine two commands as shown in the example below: toggle the exit, followed by a select command:

Code:
  <PartInfo>
    <Name>door_1</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Sim>
          <Variable>EXIT OPEN:1</Variable>
          <Units>percent</Units>
        </Sim>
      </Parameter>
    </Animation>

    <MouseRect>
      <TooltipText>Open Pilot Window</TooltipText>
      <Cursor>Hand</Cursor>
      <CallbackCode>
        (>K:TOGGLE_AIRCRAFT_EXIT,bool)
        (>K:SELECT_2,bool)
      </CallbackCode>
    </MouseRect>
  </PartInfo>

Bill,
I am still confused because it previouly worked using the keyboard Shift+E+1 and Shift+E+2 for door LH and door RH. It appears to be ignoring those entries and uses Shift+E only for Door_0 and ignoring the rest. The only time I have previously used the panel gauge entry was in my Challenger 300 cockpit.
Like I previously stated I am going to build a box and have the left and right sides open up using the correct commands and see what the results are.

will post the results when I try it.

Thanks for your time and efforts. Bill, it is greatly appreciated.

Richie

Edit update:
Bill, I have inserted the code into the modeldef.xml file and it still does not work. Doors only respond to Shift+E not to the 1,2,3 or 4 Select.
So I guess the only way to resolve this is to either repair the FSX and the SDK re-install.

Richie
 
Last edited:
Hi there,
I am happy to announce that I have isolated the problem down to two my generated gauges in the 2d panel. So now I start the process of reviewing the code to determine the fault. It has to be in the update as this is happening just afer loading the aircraft.
Thanks for all the help especially to Bill for his efforts. I always learn a few new things from each problem that I encounter.

Richie
 
This behavior is usually caused by flooding FS with K: events - they should be fired only when needed. I believe Doug Dawson has a monitoring gauge that will create a log of events as they are fired, which makes it much easier to find the problem code.
 
This behavior is usually caused by flooding FS with K: events - they should be fired only when needed. I believe Doug Dawson has a monitoring gauge that will create a log of events as they are fired, which makes it much easier to find the problem code.
Tom, thanks for your reply and this is the code in the instruments as described that was causing the problem. So therefore I would like to know how they would be affecting the door animation. The purpose of the first code was to disconnect the AP master when no function is selected.
The second one was turn off the APU when the main engine was turned of by fuel or magneto or switch by utilizing the combustion mode.
Code:
This is the code that is causing the SHIFT+E not to work correctly in the EFIS:
Code is in the update of EFIS

(A:AUTOPILOT NAV1 LOCK,bool) 1 ==  if{ (>K:AUTOPILOT_ON) } els{ (>K:AUTOPILOT_OFF) } 
(A:AUTOPILOT HEADING LOCK,bool) 1 ==  if{ (>K:AUTOPILOT_ON) } els{ (>K:AUTOPILOT_OFF) } or 
(A:AUTOPILOT ALTITUDE LOCK,bool) 1 ==  if{ (>K:AUTOPILOT_ON) } els{ (>K:AUTOPILOT_OFF) } or 
---------------------------------------------------------------------------------------------------------------------------------------------

This is the code that is causing the SHIFT+E not to work correctly in the Electrical Master Battery/Engine Start Switch:

(A:GENERAL ENG COMBUSTION:1,bool) 0 == if{ 0 (>K:APU_OFF_SWITCH) 0 (>K:APU_GENERATOR_SWITCH_SET) and }
I hope someone can lead me to the answers for future reference to avoid these difficult problem and the time it takes to locate and correct those errors that FSX does not like.
Thanks again Tom for your reply and I will keep waht you had to say in mind during any future project.

Richie
 
OK, let's look at this code. Remember that FS runs your code 18 times a second:

Code:
(A:GENERAL ENG COMBUSTION:1,bool) 0 == if{ 0 (>K:APU_OFF_SWITCH) 0 (>K:APU_GENERATOR_SWITCH_SET) and }

What is this saying? "If the engines are off, then send a message to FS to turn off the APU switch and turn off the APU generator switch." Note that this statement will be true as long as the engines are off - the K: events are sent 18 times a second.

*Every time* you send such a message, it is the same thing as someone pressing a command key (Z for the AP toggle, for example). So your gauge is causing two "keys" (K: commands used to be called "key events") to be pressed 18 times per second! Now, you are coming along and pressing E, and then 2 to get the cargo door to open. Well, how many keypresses did your gauge send to FS in between the E and the 2? Dozens! So the 2 is never read as an extension of the E command, but instead an extension of an APU command (where it is ignored).

So the trick is to send each of those K: commands ONLY ONCE. If you set up a variable called L:APU_lock, bool (as an example name) and use that as a "flag" that the K: events have already been sent, then you will avoid this problem.

Something like (not tested):

Code:
(A:GENERAL ENG COMBUSTION:1,bool) 1 == (L:APU_lock, bool) 1 == and if{ 0 (>L:APU_lock,bool) }

(A:GENERAL ENG COMBUSTION:1,bool) 0 == (L:APU_lock, bool) 0 == and if{ 0 (>K:APU_OFF_SWITCH) 0 (>K:APU_GENERATOR_SWITCH_SET)  1 (>L:APU_lock,bool) }

The logic flow:

1. Panel loaded, L:APU_lock,bool = 0. I'll call this the "L: variable" from now on.
2. If engines off, APU switched off, L: variable now = 1.
3. If engines on, L: variable stays at 0.
4. NOTHING happens (no K: events sent) until the engines are started or stopped.
5. The engines are started. Now the L: variable is set to 0. No K: events are sent.
6. The engines are stopped. Now the "if" statement is true again and the APU is shut down again.

If you want to turn the APU on when the engines are started, just add that code to the first statement.

Note: you did not need the "and" statement for the two K: variables - they will both be processed anyway.

Hope this helps,
 
Last edited:
Alternatively, check for (A:APU GENERATOR ACTIVE,bool) to see if the APU is running...

Code:
(A:GENERAL ENG COMBUSTION:1,bool) 0 == (A:APU GENERATOR ACTIVE,bool) and
    if{ 0 (>K:APU_OFF_SWITCH) 0 (>K:APU_GENERATOR_SWITCH_SET) }

The main thing, as Tom has pointed out is that you absolutely must make sure your logic only sends commands once when needed!
 
Bill.
Once again thanks for the info. As always you are the master and ACE. I appreciate all the help. Just one more question, I noticed in my FSX that even with all the add on sircraft and only default aircraft loaded, that once I use the door Shift+E+1or 2 that I lose the zoom function and the omly way to get it back is to reboot FSX. That even happens in FS9 until I change from 2d to 3d virtual and then back. I am about ready to use the repair function on the disk. Any advice?

richie
 
Richie, that happens to me quite often as well. Hit the "Backspace" key to reset the default zoom, then the in/out keys will regain focus.
 
Bill,
Thanks for the info. Also a matter of interest. Yesterday afternoon my computer started acting a bit strange so I decided to do a virus scan check with Microsoft Security and low and behold it identified a virus as this : Expoit:Java.Blocole.ba thru bi. The identified virus was removed. I do not know where I could have gotten it or when as I do not usually visit any sites other than the simming sites. I hop it did not spread. Just a word of caution.
Have a great day in your designing tasks.

Richie
 
Back
Top