• 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 Switch bool on start up

Messages
114
Country
canada
Hi, I made this switch animation in modeldef. I want to know what I need to do so the switch starts to turn on when the sim starts. Its an on-off switch, but I would like it to be on when the sim starts.

<PartInfo> <Name>switch_pedcom_left_330</Name> <AnimLength>50</AnimLength> <Animation> <Parameter> <Code> (L:switch_pedcom_left_330,bool) 50 *</Code> <Lag>400</Lag> </Parameter> </Animation> <MouseRect> <Cursor>Hand</Cursor> <TooltipText>Communications Power</TooltipText> <MouseFlags>LeftSingle+RightSingle</MouseFlags> <CallbackCode> (L:switch_pedcom_left_330, bool) ! (>L:switch_pedcom_left_330, bool) 1 (&gt;L:Switch Finger Sound rik,number) </CallbackCode> </MouseRect> </PartInfo>

Thanks!
 
The easiest way to initialize any panel or action is to add code:
XML:
         (L:Init, enum) 0 == if{ 1 (&gt;L:switch_pedcom_left_330, bool) 1 (&gt;L:Init, enum) }
Can be placed in the gauge XML code.
You can also assemble state logic by including other variables in the code for different initialization states.
In C++, the logic is approximately the same, but there you can configure the initialization more flexibly
 
Thanks! Ok, so I've added that to my gauge, although the switch wasn't turned on when the sim started.

If I changed 0 == to 1 == the switch was on, but then I couldn't toggle it on or off. Is it how I wrote the animation in the modeldef that would be affecting this, because I understand how your code should work :)
 
Leave your code
XML:
<PartInfo>
<Name>switch_pedcom_left_330</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code> (L:switch_pedcom_left_330,bool) 50 *</Code>
<Lag>400</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Communications Power</TooltipText>
<MouseFlags>LeftSingle+RightSingle</MouseFlags>
<CallbackCode>
(L:switch_pedcom_left_330, bool) ! (>L:switch_pedcom_left_330, bool)
1 (&gt;L:Switch Finger Sound rik,number)
</CallbackCode>
</MouseRect>
</PartInfo>

As it is.

To your folder Panel.хх рlace the folder there.
Register in Panel.cfg to section [Vcockpit01] gaugeXX=Init_main!Main_processor, 1,1,20,20. If initialization is needed in 2D, you can add code to the sections of the 2D panel [WindowХХ] that start when loading.
This is one way.
In C++, this is much easier to do by immediately setting the values after registering the variable or from the configuration file.
 

Attachments

  • Init_main.rar
    340 bytes · Views: 29
Last edited:
Oh yeah it works!! Thank you!
And I would also recommend the variables of the sound assign and program separately in the external code to take out the limits of the compiled in the .mdl code. This will allow you to work with the variables directly and improve the flexibility and capabilities of code and sound.
 
Back
Top