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

3 Position Switch Help

Messages
53
Hi there. While I've been relatively successful with 3 position switches using L:vars, I just can't get the following A:vars switch to work. Can anyone help?

Thanks!

Code:
<PartInfo>
      <Name>Start_Eng12</Name>
      <AnimLength>50</AnimLength>
      <Animation>
         <Parameter>
            <Code>
               25 (A:GENERAL ENG STARTER:1,bool) 25 * +
            </Code>
         </Parameter>
      </Animation>
      <MouseRect>
         <Cursor>Hand</Cursor>
      <TooltipText>Engine Start</TooltipText>
         <MouseFlags>LeftSingle+RightSingle+Wheel</MouseFlags>
         <CallbackCode>
            (M:Event) 'RightSingle' scmp 0 ==
            (M:Event) 'WheelDown' scmp 0 == or
            if{ (A:GENERAL ENG STARTER:1,bool)) -- -1 max (>A:GENERAL ENG STARTER:1,bool)) }
         
            (M:Event) 'LeftSingle' scmp 0 ==
            (M:Event) 'WheelUp' scmp 0 == or
            if{ (A:GENERAL ENG STARTER:1,bool)) ++ 1 min (>A:GENERAL ENG STARTER:1,bool)) }

            (A:GENERAL ENG STARTER:1, bool) -1 ==
            if
            {
               (A:GENERAL ENG STARTER:1,bool) -1 == if{ (A:GENERAL ENG STARTER:2, bool) ! if{ (>K:TOGGLE_STARTER2, bool) }
            }          
            (L:LLTLswitch, enum) 0 ==
            if
            {
               (A:GENERAL ENG STARTER:1,bool) if{ (&gt;K:TOGGLE_STARTER2, bool) } &amp;&amp;
            }

            (A:GENERAL ENG STARTER:1,bool 1 ==
            if
            {
               (A:GENERAL ENG STARTER:1,bool 0 == if{ (A:GENERAL ENG STARTER:2, bool)) if{ (>K:TOGGLE_STARTER2, bool) } } (A:GENERAL ENG STARTER:1,bool 1 == if{ (>K:TOGGLE_STARTER1, bool) }
            }
         </CallbackCode>
      </MouseRect>
   </PartInfo>
 
I don't know exactly if your basic code should work or not (never done one of these) but there are some problems here.

XML:
(A:GENERAL ENG STARTER:1, bool) -1 ==
            if
            {
               (A:GENERAL ENG STARTER:1,bool) -1 == if{ (A:GENERAL ENG STARTER:2, bool) ! if{ (>K:TOGGLE_STARTER2, bool) }
            }

This code tests the same thing twice, which is not efficient. Also, the if in the second line is not valid XML code, it should be if{ . You can not add a line between the if and the { . Also true for the two other locations. Second, if I am counting correctly the number of { do not equal the number of } in this Callback Code.

Next there is this statement:

XML:
(L:LLTLswitch, enum) 0 ==
            if
            {
               (A:GENERAL ENG STARTER:1,bool) if{ (&gt;K:TOGGLE_STARTER2, bool) } &amp;&amp;
            }

I have no idea how FS would interpret this code. What is the && for at the end of this line? That would normally be used in a logic section (usually to the left of the if{ ), not with a K: event.

Hope this helps,
 
Many thanks. This spread out structure works just fine with the L:vars, but I'll tighten it up and see what happens. Will also go through it again to see about those { }. Might even see if I can find a different way of writing this - XML definitely not my strong suite....
 
Where are you getting your -1 expectations from? A boolean value is only guaranteed to be ether zero (false) or non-zero (true). Neither of those ensures it will return a -1.
 
Yes, I am afraid there are many mistakes in this script, including unbalanced parentheses, value assignments to read-only variables, inconsistent mouseflags etc. Best thing to be honest would be a complete re-write. Maybe if you could explain what you want your switch to do? I gather it's a switch that has three positions, 0, 25 and 50, and when it's advanced to 25 you want to trigger Starter1 and going to 50 it would be Starter2. Is that the way the switch worked in RL? I mean, purely thinking off the top of my non-motor head, wouldn't it be more logical, or at any rate more intuitive, to design position 0 for triggering Starter1, 25 for neutral (do nothing), and 50 for Starter2? So that a left-click would start the left engine, and a right click the right engine? That wouldn't be overly complicated and I'd be happy to code you that...

--Manfred
 
A: vars can't be written to directly in XML. Also K: events shouldn't have unit types added.

For all Booleans in XML, use either 0 == or 0 !=
 
Well, that's interesting And thanks, everybody. The original gauge was written quite a few years ago by someone for a project of mine, and as mentioned, with L:vars (and minus the need for K:vars) it works just fine and so I never questioned it. XML must be smart enough to ignore a lot of things. And also helps explain (along with my low level XML skills) why I've had no luck trying to use it as the basis of a new gauge. I also wondered about some of the things mentioned here, but put it down to my lack of knowledge. Manfred, happy to accept your offer, as there's an excellent chance I'd screw it up anyway - and thanks.

Mike
 
Will do, love the challenge. Knowing the stuff you do I expect there is going to be a Start_Eng34, too?
 
Pleasure, here you go ... left click to trigger Starter1, right click for 2. Just change indices, and names, and GUID, for engines 3 and 4.

Code:
<Animation name="Start_Eng12" guid="0005068B-39AE-44f2-9F89-6F7F30DCD5AD" type="Sim" typeParam="AutoPlay" length="50" typeParam2="Start_Eng12"/>
<PartInfo>
<Name>Start_Eng12</Name>  
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
  (A:GENERAL ENG STARTER:1,bool) if{ 0 }
  els{ (A:GENERAL ENG STARTER:2,bool) if{ 50 }
  els{ 25 } }
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Starter Engines 1 and 2</TooltipText>
<MouseFlags>LeftSingle+RightSingle</MouseFlags>
<CallbackCode>
  (M:Event) 'LeftSingle' scmp 0 ==
  if{ (>K:TOGGLE_STARTER1) }
  els{ (>K:TOGGLE_STARTER2) }
</CallbackCode>
</MouseRect>
</PartInfo>
 
That appears to be flooding the sim with the TOGGLE_STARTERx event. In FS9, that would be necessary... in FSX/Prepar3D that will never start the engine as it's a true toggle event and you would literally be toggling the starter on and off each update frame.
 
One, it definitely does not flood the sim. Two, I had no brief to start the engines. All Mike wanted was the switch logic, not the full startup logic, which I assume he manages elsewhere. Of course it could also be added to the present code.
 
Back
Top