• 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 v1 3 Way Switches

Messages
10,163
Country
us-arizona
Does anyone have the time to explain the basics of making a 3 way switch. I know its a lot to ask, and at least 2 posts have been posted on this before, and they drudge along and were about making other switches appear/disappear, nothing to do with an actual 3 way switch in its truest form.


I need to know how to set up its data in the mouse config, how to know how to make one that returns to neutral, and how to make one that has 3 position points.


This is not for a gauge, this is for a 3D object (part, switch) in a plane model, a virtual cockpit.


How do you tell the part to return to a neutral point, or how to make it stay at point 2, point 3, and back to point 1? Surely this is in the mouserect section? or..?


For instance, if a person wanted to make a spoiler switch that has 'lower' or 'raise' with a return-to-neutral switch position. (Type one, lets say).


Another for instance, if one needed to make a dual starter switch for a turbine, how would you make the switch to go from off to on-left, or back to off, and then to on-right, etc.



I just need the basic structure or 'how' this works, and I can surely go from there.

I have this which I found yesterday.


Code:
<PartInfo>
    <Name>switch_light_section_off</Name>
    <Animation>
      <Parameter>
        <Code>
          25 (L:switch_light_section_off, number) 25 * +
        </Code>
       <Lag>950</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Section Light</TooltipText>
      <MouseFlags>LeftSingle+RightSingle</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 ==
        if{ (L:switch_light_section_off, enum) -- -1 max (>L:switch_light_section_off, enum) and (L:switch_light_section_on, enum) -- -1 max (>L:switch_light_section_on, enum)  }
        (M:Event) 'RightSingle' scmp 0 ==
        if{ (L:switch_light_section_off, enum) ++  1 min (>L:switch_light_section_off, enum) and (L:switch_light_section_on, enum) ++  1 min (>L:switch_light_section_on, enum) }
      </CallbackCode>
    </MouserRect>
  </PartInfo>

On this one, it only has 2 sections for the mouserect, so would this work in a track like an 'enum' where it has location points 0, 1, and 2? How would it have only 2 locations when the object switch can lock into 3 positions?

Also, Bill Leaming, you were helping this gentleman and you stated that in the top section of this, the Animation section, that it tells you there that this travels through 50 Keyframes total, so I got that. 25 and 25 total being 50 KF's. So if I wanted 100 (I animate my switches at 100 KF's), I would have 50, 50 for my animation.


so confused.......
 
Last edited:
In the above section, what I 'think' is happening, is that the top 'animation' section states that it will move 25 KF's at a time.

Then, from the MouseRect section, you right click and left click for movements, and there are 'if' statements for positions. Would this be correct?


What if you wanted to make this 'lock' back in neutral position? Like a trim tab rocker would do?
 
Just looking over some switches in the parts XML.

I am going to guess that CallbackJumpDragging initiates a 'mouse drag' switch that would travel in the X or Y or Z axis, like so....


Code:
 <PartInfo>
        <Name>lever_cowl_flaps1</Name>
        <Copy>lever_cowl_flaps</Copy>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>RECIP ENG COWL FLAP POSITION:2</Variable>
                </Sim>
            </Parameter>
        </Animation>
        <MouseRect>
            <TooltipID>TOOLTIPTEXT_ENG2_COWL_FLAPS_PERCENT</TooltipID>
            <CallbackJumpDragging>
                <YMovement>
                    <EventIdInc>INC_COWL_FLAPS2</EventIdInc>
                    <EventIdDec>DEC_COWL_FLAPS2</EventIdDec>
                </YMovement>
            </CallbackJumpDragging>
        </MouseRect>
    </PartInfo>


My question on this one is, how would you make a custom version with L:vars? I think I see that this one also does not return to its neutral position, that it would act like a flaps lever, instead of a flaps rocker.
 
Bill...
Not sure if this is what you're looking for but this code works for me using FSXA SP2. It's a 3 position 3D switch that uses a custom variable that calls back the sim variable for the primers. The mouse call back is usable with either left click, right click or the mouse wheel and the switch returns to center after buttons are released. If using the wheel you have to physically move the wheel to return the switch back to center. Animated for 100 KF with neutral or center position at KF50. Hope this helps.
Mark

Code:
  <PartInfo>
    <Name>Dual_Primer</Name>
      <AnimLength>100</AnimLength>
        <Animation>
         <Parameter>
          <Code>50 (L:PrimerToggle,enum) 50 * +</Code>
            <Lag>100</Lag>
         </Parameter>
        </Animation>
        <MouseRect>
          <Cursor>Hand</Cursor>
          <TooltipText>leftPrimer/RightPrimer</TooltipText>
          <MouseFlags>LeftSingle+LeftRelease+RightSingle+RightRelease+Wheel</MouseFlags>
            <CallbackCode>
             (M:Event) 'LeftSingle' scmp 0 ==
                    if{ -1 (>L:PrimerToggle,enum) (>K:TOGGLE_PRIMER1) (P:local time, seconds) 4.75 + (>L:Prime_reset) }

             (M:Event) 'LeftRelease' scmp 0 == 
                    if{ 0 (>L:PrimerToggle,enum) }

             (M:Event) 'RightSingle' scmp 0 ==
                    if{ 1 (>L:PrimerToggle,enum) (>K:TOGGLE_PRIMER2) (P:local time, seconds) 4.75 + (>L:Prime_reset) }

             (M:Event) 'RightRelease' scmp 0 == 
                    if{ 0 (>L:PrimerToggle,enum) }
            </CallbackCode>
          </MouseRect>
  </PartInfo>
 
Last edited:
On this one, it only has 2 sections for the mouserect, so would this work in a track like an 'enum' where it has location points 0, 1, and 2? How would it have only 2 locations when the object switch can lock into 3 positions?
Bill, note that the mouse section defines left and right click actions.

The variable values are limited to the range -1 to +1... that's three possible values: -1, 0, +1

Zero (0) is obviously the center position.

Animation for 100 frames would be: frame 0, frame 50 and frame 100

A left-click will decrement the (L:var,enum)
A right-click will increment the (L:var,enum)

In the example "redfly" posted, you could simplify the script like this:

Code:
             (M:Event) 'LeftRelease' scmp 0 ==
             (M:Event) 'RightRelease' scmp 0 == or
                    if{ 0 (>L:PrimerToggle,enum) }

However, I would also add some other possible conditions to reduce the possibility that the switch will get stuck.

Code:
             (M:Event) 'LeftRelease' scmp 0 ==
             (M:Event) 'RightRelease' scmp 0 == or
             (M:Event) 'LeftDrag' scmp 0 == or
             (M:Event) 'RightDrag' scmp 0 == or
             (M:Event) 'Leave' scmp 0 == or
                    if{ 0 (>L:PrimerToggle,enum) }
 
Thanks Bill, Thanks Mark.

I didn't think of mouse-release. Brilliant.

LeftRelease and RightRelease are for when you release the mouse button(s)

LeftDrag and RightDrag are for when your cursor slips off the mouse spot before you release the mouse button(s)

Leave is for "just in case the above don't work"

It never hurts to cover all possibilities! :D
 
Back
Top