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

FSX Primer Pump Animation Script

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
In the T-50 Bobcat, I have a "Primer Pump" that requires a complex bit of script to animate. Mouse wheel will rotate the control handle from ON Left - OFF - ON Right positions. This works just fine.

Where I'm encountering a problem however is with the in/out "pumping" animation. Currently I'm using this bit of scripting logic that does work, but unfortunately the silly thing has two sound effects of differing lengths. Pulling it out is easier and faster than pushing it back in, since like a hand insecticide sprayer, it only "pumps" on the in-stroke! In Real Life it actually needs both hands to do the pumping... :yikes:

sqUfN.jpg


So, here is the current animation/mouse script:
Code:
  <PartInfo>
    <Name>SW_PrimerPump</Name>
    <AnimLength>10</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:SW_PrimerPump,bool) 10 *</Code>
        <Lag>2.1</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>WheelDown+WheelUp+LeftRelease+LeftDrag+LeftSingle</MouseFlags>
      <CallbackCode>
        (M:Event) 'WheelDown' scmp 0 ==
        if{ (L:SW_PrimerSelect, enum) -- -1 max (&gt;L:SW_PrimerSelect, enum) 1 (&gt;L:XMLSND2,bool) }
        (M:Event) 'WheelUp' scmp 0 ==
        if{ (L:SW_PrimerSelect, enum) ++  1 min (&gt;L:SW_PrimerSelect, enum) 1 (&gt;L:XMLSND2,bool) }

(* out *)
        (M:Event) 'LeftSingle' scmp 0 ==
        (L:SW_PrimerSelect, enum) 0 != and
        if{ 1 (&gt;L:SW_PrimerPump,bool) 1 (&gt;L:XMLSND22,bool) }

(* in *)
        (M:Event) 'LeftRelease' scmp 0 ==
        (M:Event) 'LeftDrag' scmp 0 == or
        if{ 0 (&gt;L:SW_PrimerPump,bool) 1 (&gt;L:XMLSND23,bool) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>

What I'd like to do is modify the mouse section such that the first L-click would trigger the "out" stroke, and the second L-click would trigger the "in" stroke. Unfortunately, the script below will trigger the appropriate sounds, but no animation occurs, and I'm just not understanding why, which is why I'm asking for fresh eyes to provide a possible solution. If I can manage this, then I can re-script the animation for different timings to match the sound effects!
Code:
  <MouseRect>
    <Cursor>Hand</Cursor>
    <MouseFlags>WheelDown+WheelUp+LeftRelease+LeftDrag+LeftSingle</MouseFlags>
    <CallbackCode>
      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:SW_PrimerSelect, enum) -- -1 max (&gt;L:SW_PrimerSelect, enum) 1 (&gt;L:XMLSND2,bool) }
      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:SW_PrimerSelect, enum) ++  1 min (&gt;L:SW_PrimerSelect, enum) 1 (&gt;L:XMLSND2,bool) }

(* out *)
      (M:Event) 'LeftSingle' scmp 0 ==
      (L:SW_PrimerSelect, enum) 0 != and
      (L:SW_PrimerPump,bool) 0 == and
      if{ 1 (&gt;L:SW_PrimerPump,bool) 1 (&gt;L:XMLSND22,bool) }

(* in *)
      (M:Event) 'LeftSingle' scmp 0 ==
      (L:SW_PrimerSelect, enum) 0 != and
      (L:SW_PrimerPump,bool) 1 == and
      if{ 0 (&gt;L:SW_PrimerPump,bool) 1 (&gt;L:XMLSND23,bool) }
    </CallbackCode>
  </MouseRect>
 
Try to reduce the code block for the "LeftSingle" mouse event to a single one?
 
I'm not following you here. To repeat, since the two different sound files are triggered, it would seem that both the out and in stroke L-clicks are being recognized. What I'm puzzled about is that the animation is not responding to the trigger variable (L:SW_PrimerPump,bool) as it flip-flops from 0 to 1 and back to 0 again.

The first L-click sets (L:SW_PrimerPump,bool) to 1, which should cause the pump to be pulled out.
The second L-click sets (L:SW_PrimerPump,bool) back to 0, which should cause the pump to be pushed back in.

In the sim however, the silly thing just will not move at all (aside from rotating of course).

In Real Life, pump operation is in fact a two-step process, which the second script is designed to emulate.
 
Bill,

As far as I see, the Engine Primer switch has three rotating positions: ON-L OFF ON-R, and an IN-OUT movement for the pumping action that, by watching your code, seems blocked when switch is in OFF position. Am I right?

First question: The animated part, at least in the code posted, responds to (L:SW_PrimerPump,bool), which is the IN-OUT axis, and I don't see where is located the rotating animation controlled by (L:SW_PrimerSelect, enum), I assume in another part?

Second: I suppose when the switch is pulled out, it cannot support rotation, is this reasoning ok?

Those ones are only to understand how the switch really works.

Now the solution to your problem:

(M:Event) 'LeftSingle' scmp 0 == if{ Do 1 }
(M:Event) 'LeftSingle' scmp 0 == if{ Do 2 }

I'm sure you'll notice both lines are executed. So the same happens in your script, second action counteracting the first one.
Just add a quit operator in the first block:

Code:
(* out *)
(M:Event) 'LeftSingle' scmp 0 ==
(L:SW_PrimerSelect, enum) 0 != and
(L:SW_PrimerPump,bool) 0 == and
if{ 1 (&gt;L:SW_PrimerPump,bool) 1 (&gt;L:XMLSND22,bool) quit }

And should work fine

Tom
 
Tom, your guesses at how this two-part system works. Yes the "rotation" is controlled by a separate part/object:
Code:
  <PartInfo>
    <Name>SW_PrimerSelect</Name>
    <AnimLength>10</AnimLength>
    <Animation>
      <Parameter>
        <Code>5 (L:SW_PrimerSelect,enum) 5 * +</Code>
      </Parameter>
    </Animation>
  </PartInfo>
Note that it defaults to the OFF position.

<:yikes:Thud!> I was being so 'clever' with my conditions that I overlooked the obvious! Thanks, "quit" is the answer. :peanut:
 
So if the switch is actually a two part element, how do you make both parts not being visible at the same time?

Besides, can the switch rotate when it is pullet OUT? How do you handle this?

Tom
 
Tom, it's done through the magic of Link(ing)! The push/pull is the parent object, and the handle and a hidden control node do the rotation. The mouse is Attachpointed to the handle and will read the wheel and L-click scripts. All objects are visible at all times.

I'll have to add some logic to 'lock' the rotation whenever the pump is being extended and retracted. Setting (L:_PumpLock,bool) TRUE with some additional XML-Fu should work. :cool:
 
Last edited:
Tom, it's done through the magic of Link(ing)! The push/pull is the parent object, and the handle and a hidden control node do the rotation. The mouse is Attachpointed to the handle and will read the wheel and L-click scripts. All objects are visible at all times.

Thank you Bill, I am a real noob at modeling...

Tom
 
Hello to everybody

Neither more nor less, here are some of my favorite people. Thank you all for teaching us by sharing your codes to gradually get a solution.

Keep up the good work and good luck.
All the best,
Sergio.
 
Just to complete the cycle, because the Primer Pump handle requires separate timing for the out-stroke and in-stroke, I changed the number of frames from 10 to 100, then added the following in the control logic script:
Code:
    (L:SW_PrimerPump,bool) 1 ==
    (L:PPTimer,enum) 101 &lt; and
    if{ (L:PPTimer,enum) 4.05 + (>L:PPTimer,enum) }

    (L:SW_PrimerPump,bool) 0 ==
    (L:PPTimer,enum) -1 &gt; and
    if{ (L:PPTimer,enum) 1.2 - (>L:PPTimer,enum) }

    (A:GENERAL ENG COMBUSTION:1,bool) !
    (L:SW_PrimerSelect, enum) -1 == and
    (L:SW_PrimerPump,bool) ! and
    (L:PPTimer,enum) 1 &gt; and
    if{ (L:PrimePump:1,enum) 0.015 + (>L:PrimePump:1,enum) }

    (A:GENERAL ENG COMBUSTION:2,bool) !
    (L:SW_PrimerSelect, enum) 1 == and
    (L:SW_PrimerPump,bool) ! and
    (L:PPTimer,enum) 1 &gt; and
    if{ (L:PrimePump:2,enum) 0.015 + (>L:PrimePump:2,enum) }
The first two sections adjust the timing of the out-stroke to ~1.75 seconds and the in-stroke to ~5 seconds.

The next two sections will "pump up" the fuel pressure only during the 5 second in-stroke.
 
Hi,

I think unless you add an illegal character they can be anything you want. I don't think that that FS "knows" they are for a specific engine number, for example? But you do.
 
L: vars accept index numbers? I honestly did not know that. :eek:
Tom is quite correct. The use of the (fake) :index numbers is mostly for my own convenience. When I look back at this months - maybe years - down the road, the meaning will remain clear.
 
Back
Top