• 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 v4 A few questions about 3D virtual cockpit

Is that will be correct? When turning on starter switch it will be switching on and engine will be starting until N2 = 51% then starter switch is turned off automaticly.
Or not? It's incorrect?! will be: if key toggle starter on and N2 51% and below general engine starter will be on, else is off. Yes?

Your thinking is good, but the code is not.

a) Events can not be evaluated. Only simulation variables can.
b) No "KEY_" prefix for events. This is only used in C++ gauges.
c) No units in events.
d) Only a few events require values.
e) No need for an "else" condition. If the starter is on and N2 is greater than 51%, switch off the starter. You won't anything more.

Therefor:
Code:
(A:GENERAL ENG STARTER:1,bool) (A:TURB ENG N2:1,percent) 51> and if{ (>K:TOGGLE_STARTER1) }
 
I wasn't talking about mixture, I was talking about fuel switches.
 
For turbine engines I simply check for combustion as a flag to turn off the starter...
 
Code:
(A:GENERAL ENG STARTER:1,bool) (A:TURB ENG N2:1,percent) 51> and if{ (>K:TOGGLE_STARTER1) }

Not worked;-( I was try many diffrent variantes.

Here is a changed code
Code:
    <Animation name="Switch_ENG1_starter" guid="e707d6e0-7a87-44ab-8e1f-7ac2ec7ef598" length="50" type="Sim" typeParam2="Switch_ENG1_starter" typeParam="AutoPlay" />
    <PartInfo>
        <Name>Switch_ENG1_starter</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                  (>K:TOGGLE_STARTER1) (A:TURB ENG N2:1,percent) 51&lt; and if{ (A:GENERAL ENG STARTER:1,bool) } els{ (A:GENERAL ENG STARTER:1,bool) ! }
                </Code>
                <Lag>400</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <HelpID>HELPID_GAUGE_STARTER_SWITCH</HelpID>
            <TooltipID>TOOLTIPTEXT_STARTER_SWITCH</TooltipID>
            <EventID>TOGGLE_STARTER1</EventID>
        </MouseRect>
    </PartInfo>

I will continue experimented.

A rather complicated task is obtained. First, I need to add code to the <MouseRect> so that when the button is pressed it can be held down. Keep need about 1, 2 seconds then starter is coming on and we release the button. Button animated be 50kf, 0 - is unpressed, 25 - pressed and 50 is back again. I can't find example for it in modeldef. Then if fuel valve is open and starter is engine is running up and when N2 is up to 51% starter must be switching off without button animation. How to do that?
 
Last edited:
This is worked!!!!
Code:
        <Animation>
            <Parameter>
                <Code>
                 (A:GENERAL ENG STARTER:1, bool)
                 (A:TURB ENG N2:1, percent) 51 &gt;
                 and
                 if{ 0 (>K:TOGGLE_STARTER1) }
                </Code>
                <Lag>400</Lag>
            </Parameter>
        </Animation>

But I still do not know how to make the button can be kept pressed. and delayed start of the starter. need a condition over time?
Also animation on button not work.

Hmm... Cursor type "Grab" at mouseRect not working in 3D?
 
Last edited:
make a timer, count when button pressed and hold, trigger starter when in certain time and reset timer.
in another way (could be combine) add mouse release as reset timer, when timer not reach time needed
 
That code may work, but it looks god bloody awful.

a) Code driving keyframed animations is READ-ONLY. So NO EVENT IDs and NO WRITING TO L: VARS. Programming standards.
b) Variables driving keyframed animations are always supposed to have end values that correspond to the animation length.
c) Possible mouse operations are listed here: https://msdn.microsoft.com/en-us/library/cc526953.aspx#mozTocId957980 Bookmark, translate and UNDERSTAND.
d) You do not need 0-25-50 keyframes. 0 and 50 suffice.

Button:
Code:
<Animation name="Switch_ENG1_starter" guid="e707d6e0-7a87-44ab-8e1f-7ac2ec7ef598" length="50" type="Sim" typeParam2="Switch_ENG1_starter" typeParam="AutoPlay" />
<PartInfo>
<Name>Switch_ENG1_starter</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:IL-96 starter switch:1, bool) 50 *         
</Code>
<Lag>400</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Engine 1 Starter %((L:IL-96 starter switch, bool))%{if}(Pressed%((A:GENERAL ENG STARTER:1,bool))%{if}, starting%{end})%{else}(Released)%{end}</TooltipText>
<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmp 0 == if{ (L:IL-96 starter switch:1, bool) ! if{ 1 (>L:IL-96 starter switch:1, bool) } }
(M:Event) 'LeftRelease' scmp 0 == if{ (L:IL-96 starter switch:1, bool) if{ 0 (>L:IL-96 starter switch:1, bool) } }
</MouseRect>
</PartInfo>

2D gauge in [VCockpit01] section of panel.cfg:
Code:
<Gauge Name="Blah">
<Update>
<!-- Check for starter switch state -->
(L:IL-96 starter switch:1, bool)
if{
<!-- Capture current time -->
(L:IL-96 Starter Timer:1, seconds) 0 == if{ (E:ABSOLUTE TIME, seconds) (>L:IL-96 Starter Timer:1, seconds) }
<!-- If captured time is not zero, wait two seconds -->
(L:IL-96 Starter Timer:1, seconds) 0 !=
(E:ABSOLUTE TIME, seconds) (L:IL-96 Starter Timer:1, seconds) - 2 &gt; and
if{
<!-- If engine N2 is lower than 51% and starter is off, engage starter -->
(A:TURB ENG N2:1,percent) 51 &lt; (A:GENERAL ENG STARTER:1,bool) ! and if{ (>K:TOGGLE_STARTER1) }
<!-- If starter is on and the fuel valve is closed, open fuel valve -->
(A:GENERAL ENG STARTER:1,bool) (A:GENERAL ENG FUEL VALVE:1, bool) ! and if{ (>K:TOGGLE_FUEL_VALVE_ENG1) }
<!-- If N2 is greater than 51% and starter is on, disengage starter and reset timer --> 
(A:TURB ENG N2:1,percent) 51 &gt; (A:GENERAL ENG STARTER:1,bool) and if{ (>K:TOGGLE_STARTER1) (L:IL-96 Starter Timer:1, seconds) 0 != if{ 0 (>L:IL-96 Starter Timer:1, seconds) } }
}
}
<!-- Start abort or reset -->
(L:IL-96 starter switch:1, bool) !
if{
<!-- If starter is engaged, disengage it -->
(A:GENERAL ENG STARTER:1,bool) if{ (>K:TOGGLE_STARTER1) }
<!-- Reset starter switch timer, if not zero -->
(L:IL-96 Starter Timer:1, seconds) 0 != if{ 0 (>L:IL-96 Starter Timer:1, seconds) }
}
</Update>
</Gauge>

I know it's hard for you because of the languge, but you absolutely need to improve your XML skills if you want to continue implementing complicated code like this!
 
That code may work, but it looks god bloody awful.

a) Code driving keyframed animations is READ-ONLY. So NO EVENT IDs and NO WRITING TO L: VARS. Programming standards.
b) Variables driving keyframed animations are always supposed to have end values that correspond to the animation length.
c) Possible mouse operations are listed here: https://msdn.microsoft.com/en-us/library/cc526953.aspx#mozTocId957980 Bookmark, translate and UNDERSTAND.
d) You do not need 0-25-50 keyframes. 0 and 50 suffice.
Hi Bjorn ,
does visibility flag work in modeldef <MouseRect> as it does with panel system <MouseArea> ?
 
Hi Bjorn ,
does visibility flag work in modeldef <MouseRect> as it does with panel system <MouseArea> ?
rather than hide model (made it unreal), just add extra condition for mouse click command. this will make mouse command doesn't work even "mouse hand" appear.
 
Heretic, thank you again! I will try to understand and check it. You're right now it's a hard for my skill. ;-)
But it's strange, why in sdk don't have a mouse delay click for different buttons. I think many aircrafts have a button like this, when we need to click and hold mouse button a few seconds for starting something action. For example - Apu start switch on 737. And I remembered in some general aviation or helicopter was a starter ignition like this. But I think it coded by c++, unfortunately.
 
I'm C++ programmer, C++ is not difficult, easier to understand cause use normal coding, unlike XML use reverse coding.
 
But it's strange, why in sdk don't have a mouse delay click for different buttons. I think many aircrafts have a button like this, when we need to click and hold mouse button a few seconds for starting something action.
Such does exist in XML scripting. Look at the default fs9gps.xml script, particularly the clear (CLR) button. If one holds the CLR button down for several seconds, it will return one immediately to the "Home Page". Quick clicks will sequence through the "De-Clutter Map" feature.
 
Guys, what the hell.. Try to add speed selector knob to the autopilot panel, in 3d offcourse, but knob make a only one time 360 degrees and stopped. Animation length is 360 (0, 90, 180, 270, 360 by same keyframes).
I've been take AUTOPILOT AIRSPEED HOLD VAR in knots and multiply it by 36 (it's give me 10 times click by mouse wheel for make a full turn) - in animation section. And CallbackJumpDragging with event increase and decrease in mouserect section. Unfortunately, I was writing from phone and don't have a code for example, but code like in kholsman knob. How to make it rotate continues? I also search by forum, but don't find answer.
 
Guys, what the hell.. Try to add speed selector knob to the autopilot panel, in 3d offcourse, but knob make a only one time 360 degrees and stopped. Animation length is 360 (0, 90, 180, 270, 360 by same keyframes).
I've been take AUTOPILOT AIRSPEED HOLD VAR in knots and multiply it by 36 (it's give me 10 times click by mouse wheel for make a full turn) - in animation section. And CallbackJumpDragging with event increase and decrease in mouserect section. Unfortunately, I was writing from phone and don't have a code for example, but code like in kholsman knob. How to make it rotate continues? I also search by forum, but don't find answer.

Hi , Don't make the Knob animation dependent on the IAS number but driven by an L:var that you have control of. for example this is my code for an Altitude target selection knob. the variable controlling the animation is (L:ALT_Knob, number) so when the user left clicks or uses mouse wheel down the following happen:
1- (&gt;K:AP_ALT_VAR_DEC) so the actual selected altitude decreases.
2- (L:ALT_Knob, number) 5 - (>L:ALT_Knob, number) , So the animation variable decreases by 5 , However it also limited between 0 and 100 so if you keep decreasing and reach 0 it will cycle back to 100 . since animation variable is decreasing the corresponding key frames of animation will decrease (reverse animation) so for my knob it will continue to rotate counter clockwise regardless of the actual altitude value, and vice versa.


Code:
    <PartInfo>
    <Name>HA420_knob_alt</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:ALT_Knob, number)
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>selected ALT %((A:AUTOPILOT ALTITUDE LOCK VAR,Feet))%!2.2f!</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle'  scmp 0 ==
        (M:Event) 'WheelDown'   scmp 0 == or
             if{ (&gt;K:AP_ALT_VAR_DEC)
                        (L:ALT_Knob, number) 5 - (>L:ALT_Knob, number)
                        (L:ALT_Knob, number) 99 &gt; if{ 0 (>L:ALT_Knob, number) }
                        (L:ALT_Knob, number) 0 &lt; if{ 99 (>L:ALT_Knob, number) }
                        }

        (M:Event) 'RightSingle' scmp 0 ==
        (M:Event) 'WheelUp'     scmp 0 == or
                                if{ (&gt;K:AP_ALT_VAR_INC)
                        (L:ALT_Knob, number) 5 + (>L:ALT_Knob, number)
                        (L:ALT_Knob, number) 99 &gt; if{ 0 (>L:ALT_Knob, number) }
                        (L:ALT_Knob, number) 0 &lt; if{ 99 (>L:ALT_Knob, number) }
                        }
        7 (>L:knbsound,bool)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Oh, I think I understand it. If I need custom animation with some default function I need to use my custom L:vars in animation section of the PartInfo in modeldef.xml, for make a conditions of it (rotate, push etc) and sawing this animation like I want and K:vars from sdk for do some default action.
For example if I want two buttons for autopilot (first is swithing on it, second - off), I need to use L:autopilot_on 50 * in animation section of this button and K:AUTOPILOT_ON in mouserect section. Also for "off" button. That's correct?
 
Oh, I think I understand it. If I need custom animation with some default function I need to use my custom L:vars in animation section of the PartInfo in modeldef.xml, for make a conditions of it (rotate, push etc) and sawing this animation like I want and K:vars from sdk for do some default action.
For example if I want two buttons for autopilot (first is swithing on it, second - off), I need to use L:autopilot_on 50 * in animation section of this button and K:AUTOPILOT_ON in mouserect section. Also for "off" button. That's correct?
Yeah, that's how i do it, seperate animation variables for knobs and switches. I use the A:variables as animation drivers only for animations that are linked to their actual value.. like for example an airspeed needle deffinately needs to be driven by (A:indicated airspeed,Knots)
 
Thanks for response! I'll try to check it.
Now a new question. What about autopilot? Any chance to do it custom by xml? I saw PID speed control by Heretic, but I don't understand how to use it.
First - when autopilot button is on, aircraft maintain pitch and bank angels what it have on the moment of switching on, or if bank was less of 4 degree, airplane set bank to 0 and back and maintain heading what it have on the moment of switching on ap. Is it do that by default? Also in this mode pilot may control the aircraft for change pitch or bank for heading by the yoke and rudder pedals. How to do it? Everything must be written by code with conditions in mouserect section?
 
Back
Top