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

P3D v2 Turbine Starter Switch

Man, I have no idea how to create a gauge that reads mouse input.

No need to create such a gauge Bill. Just by adding the red part:

(M:Event) 'LeftDrag' scmp 0 ==
if{
(M:Y) (>L:MousePixel,number)
(M:Y) (L:LEFT GEN MOUSEPOS,number) - 1 * (L:LEFT GEN SELECT_POS,number) + -25 max 25 min (>L:LEFT GEN SELECT_POS,number)
(M:Y) (>L:LEFT GEN MOUSEPOS,number)
}
etc...


in your current snippet, and afterwards reading (L:MousePixel,number) values while you drag the cursor from top to bottom should be enough.
To read those values, you can use whatever gauge in any 2D popup panel of your aircraft that displays a <Text> element, adding something like <String>%((L:MousePixel,number))%!s!<String>.

man.... If only there were classes on this.

Bill, the entire FSDeveloper forum is a big classroom. Indeed there are enough info here related to the stuff posted in this thread, but as you has already noticed, a bit of time needs to be invested in finding a proper solution to each question.

Tom
 
You know, from what I am hearing, how the XML Parser was redone for P3D V2.1, with all the gauges that are crashing now (with V2.1), this could be why I am not getting any results.
 
Bill, I doubt all of your issues are happening because of P3D2.1 version. But I'm interested to know how do you know about changes in the XML Parser; did you take it from LM sdk info? or maybe from someone working at LM (a spokesman/woman?).

Tom
 
Jessica Bannister, Editor at PC Pilot magazine told me that LM had revamped the XML parser in the sim with Build 2.1.
 
See the thread on using the new error reporting feature to generate a text list of all XML errors. According to a brief test, my C310R has more than 900 such 'syntax errors' when loaded in P3Dv2.1 although I think many of them are duplicated.

In any event, I'm going to comment out all XML gauges in my panel.cfg file and find/fix all such errors one at a time until they are all "sanitized" and "verified..." <sigh> :(
 
Jessica Bannister, Editor at PC Pilot magazine told me that LM had revamped the XML parser in the sim with Build 2.1.

Well, I know the parser was indeed changed in V2.0 to support Lua scripts embedded in standard XML scripts. Maybe this is affecting the typical behavior (FSX)? I don't know, and I can't make any test because I don't have P3D installed.
But Bill Leaming (n4gix) stated in another thread that perhaps ">" symbol is not accepted anymore in V2.1, only the primitive &gt; will work. If this is the case, then you're right and the approach in message #7 won't work as it is coded. I'm afraid you'll have to test by yourself.

Tom
 
Having had a closer look at the error text file that P3Dv2.1 produced, I note that many of the "errors" are identical across the entire script, which means that a global search and replace should fix probably more than half of 'em in one whack...
 
Well, I have P3D V2.0 working again on my computer, and so the nightmare continues, to make a 3 way switch with hold-down flip-return on the starter mode.
 
Ok, getting much closer now. A little progress and some learning and discoveries.

Problem 1; the starter comes on at the top stroke, and stays on. (The starter should only be on when holding down the mouse button, and the switch is in the bottom stroke area, 0-ish range). Repeating an upstroke turns the starter back off.
Problem 2; The bottom stroke should always return to middle, so middle is always the starting point unless the Generator is on. I haven't figured out a way to get that working, so I may have to do an external invisible gauge to get that working right.

Figured out how to reverse the mouse-drag motion via a code Vitus had done. Figuring out scaling. Still a ways to go though.



Code:
<PartInfo>
        <Name>learjet24_gen_left</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
              <Code>
                 (L:LEFT_GEN_SELECT_POS,number)
              </Code>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>Left Generator Starter Selector</TooltipText>
    <MouseFlags>LeftSingle+LeftRelease+LeftDrag+Wheel</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
                 1 (&gt;L:XMLSND1,enum)
        quit
      }
   
      (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:LEFT_GEN_MOUSEPOS,number) - -0.8 * (L:LEFT_GEN_SELECT_POS,number) + 0 max 50 min (&gt;L:LEFT_GEN_SELECT_POS,number)
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
      }
   
      (M:Event) 'LeftRelease' scmp 0 ==
      if{
            (M:Y) (L:LEFT_GEN_SELECT_POS,number) 15 &lt;
        if{
                 0 (&gt;L:LEFT_GEN_SELECT_POS,number)
        }
        (M:Y) 16 24 (L:SELECT_POS,number) rng
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
        }
        (M:Y) (L:LEFT_GEN_SELECT_POS,number) 25 &gt;
        if{
                50 (&gt;L:LEFT_GEN_SELECT_POS,number)
                   (>K:TOGGLE_ALTERNATOR2)
           (>K:TOGGLE_STARTER1)
        }
                 1 (&gt;L:XMLSND1,enum)
      }
            </CallbackCode>
        </MouseRect>
    </PartInfo>
 
Man! Its almost there! I think like 90 to 95% there!

Breakthrough; Switch returns to off from Starter hold-down mode. Now working.
Breakthrough; Switch will move from off to Generator 'on' position (up) and stay, and can be turned off (dragged down to off position)
Breakthrough; all clicks working

Problem; Holding down the switch in 'Starter' position (full down) is unstable. Sometimes the starter stops, and if you keep dragging the mouse, the starter does a blipping of on/off/on/off..... Any idea's on how to stop that? I inserted 'quit' in two sections to see if I could stop that. It will work ok if you find its sweet spot, but 2 times out of 3 you will accidentally turn it on, and it can stay on. It must be the holding down and moving that is causing the de-synching with 'hold on' then release-turn-off.

Problem 2; Cannot get the Alternator to turn on when in up position.

Code so far;

Code:
<!--learjet24_gen_left-->
 
<PartInfo>
        <Name>learjet24_gen_left</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
              <Code>
                 (L:LEFT_GEN_SELECT_POS,number)
              </Code>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>Left Generator Starter Selector</TooltipText>
    <MouseFlags>LeftSingle+LeftRelease+LeftDrag+Wheel</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
                 1 (&gt;L:XMLSND1,enum)
        quit
      }
    
      (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:LEFT_GEN_MOUSEPOS,number) - -0.8 * (L:LEFT_GEN_SELECT_POS,number) + 0 max 50 min (&gt;L:LEFT_GEN_SELECT_POS,number)
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
            (M:Y) (L:LEFT_GEN_SELECT_POS,number) 2 &lt;
            if{ (>K:TOGGLE_STARTER1) }
              quit
      }
    
      (M:Event) 'LeftRelease' scmp 0 ==
      if{
            (M:Y) (L:LEFT_GEN_SELECT_POS,number) 5 &lt;
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
                 1 (&gt;L:XMLSND1,enum)
                   (>K:TOGGLE_STARTER1)
                   quit
        }
        (M:Y) 6 45 (L:SELECT_POS,number) rng
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
        }
        (M:Y) (L:LEFT_GEN_SELECT_POS,number) 46 &gt;
        if{
                50 (&gt;L:LEFT_GEN_SELECT_POS,number)
                   (>K:TOGGLE_ALTERNATOR2)
        }
      }
            </CallbackCode>
        </MouseRect>
    </PartInfo>


Note the Animation 'Code' section. Extreme simplicity. I found this on an old code by Vitus. Couldn't believe how simple and it works very well.
 
Something I learned on this last night;

When you have an (M:Event) with mouse type, then you have a mouse drag section like (M:Y), the (M:Y) must be next to 'each and every sub string' function that will be under that (M:Event) section. Each event that is 'moused' must start with M:Y or M:X. I didn't know that.

Something odd in codes I was studying is that sometimes people put something like 100 in front of (M:Y). I haven't figured that out yet.
 
Found a flaw....

This
(M:Y) 6 45 (L:SELECT_POS,number) rng

......should be
(M:Y) 6 45 (L:LEFT_GEN_SELECT_POS,number) rng


and testing continues...
 
Progress.... Got the Generators (Alternators) to turn on/off. hoooo rah!

Still no luck getting anything to work with making the Starters run 'only when holding down' the mouse at zero pixel range (mouse drag, 3 &lt; or 0 ==, etc).

Switches animation is 99% right on...

Code:
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
                 1 (&gt;L:XMLSND1,enum)
        quit
      }
     
      (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:LEFT_GEN_MOUSEPOS,number) - -1.1 * (L:LEFT_GEN_SELECT_POS,number) + 0 max 50 min (&gt;L:LEFT_GEN_SELECT_POS,number)
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
                   quit
                  (L:RIGHT_GEN_SELECT_POS,number) 0 &lt;
                    if{ (A:GENERAL ENG STARTER:1, bool) 0 ==
                      if{ (>K:TOGGLE_STARTER1) } }
      }
     
      (M:Event) 'LeftRelease' scmp 0 ==
      if{
            (M:Y) (L:LEFT_GEN_SELECT_POS,number) 5 &lt;
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
                 1 (&gt;L:XMLSND1,enum)

        }
        (M:Y) 6 45 (L:LEFT_GEN_SELECT_POS,number) rng
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
                   (A:GENERAL ENG GENERATOR SWITCH:1, bool) 1 ==
                     if{ (>K:TOGGLE_ALTERNATOR1) }
                   (A:GENERAL ENG STARTER:1, bool) 1 ==
                     if{ (>K:TOGGLE_STARTER1) }

        }
        (M:Y) (L:LEFT_GEN_SELECT_POS,number) 46 &gt;
        if{
                50 (&gt;L:LEFT_GEN_SELECT_POS,number)
                   (>K:TOGGLE_ALTERNATOR1)
        }
      }
            </CallbackCode>
 
OK! Victory! 3 weeks later, it is done!

This is a 3 way switch, flip up, hold down, and middle is off. This is a starter switch and generator switch 2-in-1. The starter is 'hold down' only, and when you release the mouse hold on it, it flips back up to middle (off) position. You can then flip it up (mouse drag) and it clicks neatly into up into generator/alternator on position.

This requires an outside invisible XML gauge that shadows and helps run the system. I could not get the started to function 'in' the ModelDef section, so I was able to do this with the help of the XML gauge. The XML gauge also turns off the jet starters (which normally start up 'on' in booting up into a jet). It also brings the switches into 'off' position, synchronizing them with the sim when you boot up into the sim.


ModelDef switch code;

Code:
  <Animation name="learjet24_gen_left" guid="c1d922fb-6308-4716-87a8-1f6b09697ebc" length="100" type="Sim" typeParam2="learjet24_gen_left" typeParam="AutoPlay"
/> 
  <Animation name="learjet24_gen_right" guid="40d481eb-9bdd-4b50-9e04-758cf24b5001" length="50" type="Sim" typeParam2="learjet24_gen_right"
typeParam="AutoPlay" />


Code:
<!--learjet24_gen_left-->
 
<PartInfo>
        <Name>learjet24_gen_left</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
              <Code>
                 (L:LEFT_GEN_SELECT_POS,number)
              </Code>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>Left Generator Starter Selector</TooltipText>
    <MouseFlags>LeftSingle+LeftRelease+LeftDrag+Wheel</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
                 1 (&gt;L:XMLSND1,enum)
        quit
      }
    
      (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:LEFT_GEN_MOUSEPOS,number) - -1.0 * (L:LEFT_GEN_SELECT_POS,number) + 0 max 50 min (&gt;L:LEFT_GEN_SELECT_POS,number)
        (M:Y) (&gt;L:LEFT_GEN_MOUSEPOS,number)
                   quit
            (M:Y) (L:RIGHT_GEN_SELECT_POS,number) 3 &lt;
                    if{ (A:GENERAL ENG STARTER:1, bool) 0 ==
                      if{ (>K:TOGGLE_STARTER1) } }
      }
    
      (M:Event) 'LeftRelease' scmp 0 ==
      if{
            (M:Y) (L:LEFT_GEN_SELECT_POS,number) 5 &lt;
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
                 1 (&gt;L:XMLSND1,enum)

        }
        (M:Y) 6 45 (L:LEFT_GEN_SELECT_POS,number) rng
        if{
                25 (&gt;L:LEFT_GEN_SELECT_POS,number)
                   (A:GENERAL ENG GENERATOR SWITCH:1, bool) 1 ==
                     if{ (>K:TOGGLE_ALTERNATOR1) }
                   (A:GENERAL ENG STARTER:1, bool) 1 ==
                     if{ (>K:TOGGLE_STARTER1) }

        }
        (M:Y) (L:LEFT_GEN_SELECT_POS,number) 46 &gt;
        if{
                50 (&gt;L:LEFT_GEN_SELECT_POS,number)
                   (>K:TOGGLE_ALTERNATOR1)
        }
      }
            </CallbackCode>
        </MouseRect>
    </PartInfo>

Code:
<!--learjet24_gen_right-->

<PartInfo>
        <Name>learjet24_gen_right</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
              <Code>
                 (L:RIGHT_GEN_SELECT_POS,number)
              </Code>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>Right Generator Starter Selector</TooltipText>
    <MouseFlags>LeftSingle+LeftRelease+LeftDrag+Wheel</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{
        (M:Y) (&gt;L:RIGHT_GEN_MOUSEPOS,number)
                 1 (&gt;L:XMLSND1,enum)
        quit
      }
    
      (M:Event) 'LeftDrag' scmp 0 ==
      if{
        (M:Y) (L:RIGHT_GEN_MOUSEPOS,number) - -1.1 * (L:RIGHT_GEN_SELECT_POS,number) + 0 max 50 min (&gt;L:RIGHT_GEN_SELECT_POS,number)
        (M:Y) (&gt;L:RIGHT_GEN_MOUSEPOS,number)
              quit
                  (L:RIGHT_GEN_SELECT_POS,number) 0 &lt;
                    if{ (A:GENERAL ENG STARTER:2, bool) 0 ==
                      if{ (>K:TOGGLE_STARTER2) } }
      }
    
      (M:Event) 'LeftRelease' scmp 0 ==
      if{
            (M:Y) (L:RIGHT_GEN_SELECT_POS,number) 5 &lt;
        if{
                25 (&gt;L:RIGHT_GEN_SELECT_POS,number)
                 1 (&gt;L:XMLSND1,enum)
        }
        (M:Y) 6 45 (L:RIGHT_GEN_SELECT_POS,number) rng
        if{
                25 (&gt;L:RIGHT_GEN_SELECT_POS,number)
                   (A:GENERAL ENG GENERATOR SWITCH:2, bool) 1 ==
                     if{ (>K:TOGGLE_ALTERNATOR2) }
                   (A:GENERAL ENG STARTER:2, bool) 1 ==
                     if{ (>K:TOGGLE_STARTER2) }
        }
        (M:Y) (L:RIGHT_GEN_SELECT_POS,number) 46 &gt;
        if{
                50 (&gt;L:RIGHT_GEN_SELECT_POS,number)
                   (>K:TOGGLE_ALTERNATOR2)
        }
      }
            </CallbackCode>
        </MouseRect>
    </PartInfo>


This is the hidden gauge that turns things on and off on bootup of the plane as well as manages the Starter on/off control.


Code:
<Gauge Name="System Sync" Version="1.0">
  <Size X="5" Y="5" />


<Element>
<Select>
<Value>
(L:Has_Initialized, bool) ! if{
    1 (>L:LJ24 HYDRAULIC PUMP, bool)
    1 (>L:LJ24B BATT MASTER LEFT, bool)
    1 (>L:LJ24B BATT MASTER RIGHT, bool)
   25 (>L:LEFT_GEN_SELECT_POS,number)
   25 (>L:RIGHT_GEN_SELECT_POS,number)
      (>K:TOGGLE_STARTER1)
      (>K:TOGGLE_STARTER2)
      (>K:TOGGLE_ALTERNATOR1)
      (>K:TOGGLE_ALTERNATOR2)
    1 (>L:Has_initialized, bool)
      }
  </Value>
</Select>
</Element>


<!-- Activate Left Starter -->

<Element>
<Select>
<Value>
       (L:LEFT_GEN_SELECT_POS,number) 1 &lt;
       (A:GENERAL ENG STARTER:1, bool) 0 ==
       and
          if{ (>K:TOGGLE_STARTER1) }
         els{ 0 }
  </Value>
</Select>
</Element>


<!-- Activate Right Starter -->

<Element>
<Select>
<Value>
       (L:RIGHT_GEN_SELECT_POS,number) 1 &lt;
       (A:GENERAL ENG STARTER:2, bool) 0 ==
       and
          if{ (>K:TOGGLE_STARTER2) }
         els{ 0 }
  </Value>
</Select>
</Element>



</Gauge>


Whats cool about this is that it replicates actual 'flipping' of the switch. It starts in 'off' position and neatly works from center in both up and down directions.

Note this uses click sounds (SND files) so you will need a sound system for using those. See Doug Dawson or Bill Leaming for one of those. The click sounds are also designed in this gauge to work with Down movement, and then release, so you click down/hold/then release 'click' when it flips back up to off position.

Thanks to everyone for helping me out. Thanks Tom Taquilo for your immense input. I am very greatful.
 
Back
Top