• 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-way switch

Messages
106
Country
germany
is it possible to create a switch with 3 ways and beginn at the middle position?

the "XX" in the graphic are the keyframes.
switch.png


if is possible, how must i write the code

Code:
<PartInfo>
        <Name>Switch_test</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                    (L:testswitch,enum) 50 * +
                </Code>
                <Lag>200</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>Switch test (%((L:testswitch,enum))%{case}%{:0}0%{:1}1%{:2}2%{end})</TooltipText>		
            <MouseFlags>LeftSingle+LeftRelease+RightSingle+RightRelease</MouseFlags>
        <CallbackCode>
(M:Event) 'RightSingle' scmp 0 == 
 if{ (L:testswitch,enum) ++ 2 min (&gt;L:testswitch,enum) }

(M:Event) 'LeftSingle' scmp 0 == 
 if{ (L:testswitch,enum) -- -1 max (&gt;L:testswitch,enum) } 
} 1 (&gt;L:push_1,enum)

(L:testswitch, enum) -1 == if{ (&gt;L:testswitch,enum) (&gt;L:testswitch,enum)}

      (L:testswitch, enum) 1 == if{ (&gt;L:testswitch,enum) (&gt;L:testswitch,enum)}

(L:testswitch, enum) 0 == (L:testswitch,enum) 1 == and if{ (&gt;L:testswitch,enum) }
(L:testswitch, enum) 1 == (L:testswitch,enum) 2 == and if{ (&gt;L:testswitch,enum) }}
</CallbackCode>
        </MouseRect>
</PartInfo>
 
Simple, add 50 to your <Code> section:

Code:
                <Code>
                    [COLOR="Red"]50[/COLOR] (L:testswitch,enum) 50 * [COLOR="red"]+[/COLOR]
                </Code>

This sets frame 50 equal to an L:var value of 0...

LVar................Frame #
-1 * 50 + 50 = 0
+0 * 50 + 50 = 50
+1 * 50 + 50 = 100

You also need to adjust the mouse section so you generate the three possible values -1, 0, +1 only:
Code:
        (M:Event) 'LeftSingle' scmp 0 ==
        if{ (L:testswitch, enum) ++ [COLOR="red"]1 min [/COLOR](>L:testswitch, enum) }

        (M:Event) 'RightSingle' scmp 0 ==
        if{ (L:testswitch, enum) -- [COLOR="red"]-1 max [/COLOR](>L:testswitch, enum) }
 
Last edited:
Code:
<PartInfo>
<Name>Switch_test</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>
(L:testswitch,enum) 50 *
</Code>
<Lag>200</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Switch test (%((L:testswitch,enum))%{case}%{:0}0%{:1}1%{:2}2%{end})</TooltipText>		
 <MouseFlags>LeftSingle+RightSingle</MouseFlags>
<CallbackCode>
(M:Event) 'RightSingle' scmp 0 == 
 if{ (L:testswitch,enum) 0 ==
  if{ 2 (&gt;L:testswitch,enum) }
  els{ (L:testswitch,enum) 1 ==
   if{ 0 (&gt;L:testswitch,enum) } } }

(M:Event) 'LeftSingle' scmp 0 == 
 if{ (L:testswitch,enum) 0 ==
  if{ 1 (&gt;L:testswitch,enum) }
  els{ (L:testswitch,enum) 2 ==
   if{ 0 (&gt;L:testswitch,enum) } } }

</CallbackCode>
</MouseRect>
</PartInfo>

Basically, right clicking moves the switch up, left clicking moves it down.
 
Basically, right clicking moves the switch up, left clicking moves it down.
What is the default "starting position?" Remember, the OP specified:
"3 ways and beginn at the middle position?"

All L:vars initialize with a value of zero (0), so the value-frame matrix must take that into account.
 
default position is in the middle.
right-click down, left-click up or reversed

Well yes, I understood that already. My question was directed to Heretic since he seems to have missed that detail... :p
 
Well yes, I understood that already. My question was directed to Heretic since he seems to have missed that detail... :p

Why? If Mijo sets the middle position at keyframe 0 and up and down to 2 and 1 respectively, he'll get what he wanted. :confused:
 
Why? If Mijo sets the middle position at keyframe 0 and up and down to 2 and 1 respectively, he'll get what he wanted. :confused:

Well yes, that is true of course, although it is counter-intuitive and you didn't specify that detail via a matrix example... ;)
 
Back
Top