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

FSX:SE Initialise / Set Variable values on aircraft load up

Messages
45
Country
australia
Hi all,

I'm sure I read somewhere on the wide world of web ages ago that it was possible to initialise / set L:Var values on aircraft load up as a one-off action (ie, it doesn't refresh like a gauge does).

I've been looking around and can't find any help on this though.

Can anyone assist, or point me in the right direction? I simply want to be able to assign initial variables to a number of L:Vars I'm using in my code (FSX:SE).

Ta!

Trent
 
Just have a if section with a toggle in it. When the gauge runs for the first time, the L:Vars are initialised then the toggle is toggled.
This is a simple one with just one L:Var to be initialised;

XML:
<Element>
  <Select>
    <Value>(L:ADF_Init,Bool) 0 == if{ 100 (&gt;L:ADFStdby,kHz) 1 (&gt;L:ADF_Init,Bool) }</Value>
  </Select>
</Element>
 
Can anyone assist, or point me in the right direction? I simply want to be able to assign initial variables to a number of L:Vars I'm using in my code (FSX:SE).
Trent, I have posted similar examples before, but here is one for a project still under development. What is important is that this is a tiny 'invisible' gauge that is placed as the last entry in the [Vcockpit01] section of the panel.cfg file: gauge09=TW_XMLGauges!TW_Logic, 0,0,1,1

This entire bit of scripted logic is placed in an <Update> section. Notice that the very first statement is a conditional:
Code:
(L:DoOnce,bool) ! if{
     .....
1 (>L:DoOnce,bool)
}
The statements in between "...." are only executed once. This is how the initialization takes place. Note also that there are two other conditional sub-clauses contained within the "DoOnce" clause. This allows me to set variable conditions differently depending on whether the user chosen the "Cold and Dark" or "Ready to Fly" option. :cool:

This example is not intended to overwhelm you, but simply to show that you can make your initialization routine as simple or complex as needed. :teacher:
Code:
<Gauge Name="Logic" Version="1.0">
    <Image Name="Transparent_rect.bmp" ImageSizes="500,128" />

    <!-- CHECK IN THE DME.XML FOR THESE -> Fuel Flow and CHT (L:vars) -->

  <Update Frequency="1">
 
    (L:DoOnce,bool) ! if{
   
    <!-- COLD AND DARK -->
    (L:C310_ColdDark, bool) (L:FirstLoad,bool) ! and (A:SIM ON GROUND,bool) and
    if{
    1 (>K:PARKING_BRAKES,bool)
    1 (>L:C310_Pilot,bool)
    0 (>L:C310_Chocks,bool)
    0 (>L:C310_Covers,bool)
    0 (>L:SwitchLL,enum)
    (A:LIGHT TAXI,bool) if{ (>K:TOGGLE_TAXI_LIGHTS) }
    0 (>L:LeftMag_Left, number)
    0 (>L:LeftMag_Right, number)
    0 (>L:RightMag_Left, number)
    0 (>L:RightMag_Right, number)
    0 (>K:MIXTURE1_SET)
    0 (>K:MIXTURE2_SET)
    0 (>K:COWLFLAP1_SET)
    0 (>K:COWLFLAP2_SET)
    (>K:PANEL_LIGHTS_OFF)
    0 (>L:SwitchEngLts, enum)
    0 (>L:SwitchRadioLts, enum)
    0 (>L:SwitchFLTLts, enum)
    0 (>L:SwitchPNLLts, enum)
    (A:LIGHT BEACON,bool) if{ (>K:TOGGLE_BEACON_LIGHTS) }
    (A:LIGHT STROBE,bool) if{ (>K:STROBES_TOGGLE) }
    (A:LIGHT NAV,bool) if{ (>K:TOGGLE_NAV_LIGHTS) }
    (A:AVIONICS MASTER SWITCH,bool) if{ (>K:TOGGLE_AVIONICS_MASTER) }
    (A:ELECTRICAL MASTER BATTERY,bool) if{ (>K:TOGGLE_MASTER_BATTERY) }
    (A:GENERAL ENG MASTER ALTERNATOR:1,bool) if{ (>K:TOGGLE_ALTERNATOR1) }
    (A:GENERAL ENG MASTER ALTERNATOR:2,bool) if{ (>K:TOGGLE_ALTERNATOR2) }
    0 (&gt;K:FUEL_SELECTOR_SET)
    0 (>L:FuelKnob:1, enum)
    0 (&gt;K:FUEL_SELECTOR_2_SET)
    0 (>L:FuelKnob:2, enum)
    (>K:ENGINE_AUTO_SHUTDOWN)
    1 (>L:FirstLoad,bool)
    }

    <!-- Flip Magnetos if Engines are Running when loaded  -->
    (L:C310_ColdDark, bool) ! (L:FirstLoad,bool) ! and (A:SIM ON GROUND,bool) ! or
    if{
    16384 (>K:MIXTURE1_SET)
    16384 (>K:MIXTURE2_SET)
    1 (>L:LeftMag_Left, number)
    1 (>L:LeftMag_Right, number)
    1 (>L:RightMag_Left, number)
    1 (>L:RightMag_Right, number)
    (>K:TOGGLE_STARTER1)
    (>K:TOGGLE_STARTER2)
    0 (>L:C310_Pilot,bool)
    1 (>L:C310_Chocks,bool)
    1 (>L:C310_Covers,bool)

    0 (&gt;K:FUEL_SELECTOR_SET)
    19 (&gt;K:FUEL_SELECTOR_SET)
    2 (>L:FuelKnob:1, enum)
    0 (&gt;K:FUEL_SELECTOR_2_SET)
    20 (&gt;K:FUEL_SELECTOR_2_SET)
    2 (>L:FuelKnob:2, enum)

    (A:CIRCUIT AVIONICS ON,bool) if{ 0 (>L:Avionics_On_Init,enum) }
    (A:ANTISKID BRAKES ACTIVE,bool) 0 == if{ (>K:ANTISKID_BRAKES_TOGGLE) }
    (A:LIGHT LANDING,bool) if{ 2 (>L:SwitchLL,enum) }
    (>K:PANEL_LIGHTS_OFF)
    (A:LIGHT BEACON,bool) ! if{ (>K:TOGGLE_BEACON_LIGHTS) }
    (A:LIGHT STROBE,bool) ! if{ (>K:STROBES_TOGGLE) }
    (A:LIGHT NAV,bool) ! if{ (>K:TOGGLE_NAV_LIGHTS) }

    16383 (>K:COWLFLAP1_SET)
    16383 (>K:COWLFLAP2_SET)

    (A:ELECTRICAL MASTER BATTERY,bool) ! if{ (>K:TOGGLE_MASTER_BATTERY) }
    (A:GENERAL ENG MASTER ALTERNATOR:1,bool) ! if{ (>K:TOGGLE_ALTERNATOR1) }
    (A:GENERAL ENG MASTER ALTERNATOR:2,bool) ! if{ (>K:TOGGLE_ALTERNATOR2) }
    (A:AVIONICS MASTER SWITCH,bool) ! if{ (>K:TOGGLE_AVIONICS_MASTER) }
    (>K:ENGINE_AUTO_START)
    1 (>L:FirstLoad,bool)
    }

    1 (>L:DoOnce,bool)
    }
<!-- END OF INITIALIZATION SECTION -->

<!-- BEGIN CONTINUOUS UPDATE SECTION -->

    (A:GENERAL ENG PROPELLER LEVER POSITION:1,percent) 0 > (L:Prop1_Feathered,bool) and if{ 0 (>L:Prop1_Feathered,bool) }
    (A:GENERAL ENG PROPELLER LEVER POSITION:2,percent) 0 > (L:Prop2_Feathered,bool) and if{ 0 (>L:Prop2_Feathered,bool) }

    (L:LeftMag_Left, number) ! (L:LeftMag_Right, number) !  and   if{ (>K:MAGNETO1_OFF) }
    (L:LeftMag_Left, number)   (L:LeftMag_Right, number) !  and   if{ (>K:MAGNETO1_LEFT) }
    (L:LeftMag_Left, number) ! (L:LeftMag_Right, number)    and   if{ (>K:MAGNETO1_RIGHT) }
    (A:RECIP ENG LEFT MAGNETO:1,bool) ! (L:LeftMag_Left, number)  (L:LeftMag_Right, number) and and if{ (>K:MAGNETO1_BOTH) }

    (L:RightMag_Left, number) ! (L:RightMag_Right, number) !  and   if{ (>K:MAGNETO2_OFF) }
    (L:RightMag_Left, number)   (L:RightMag_Right, number) !  and   if{ (>K:MAGNETO2_LEFT) }
    (L:RightMag_Left, number) ! (L:RightMag_Right, number)    and   if{ (>K:MAGNETO2_RIGHT) }
    (A:RECIP ENG LEFT MAGNETO:2,bool) ! (L:RightMag_Left, number)   (L:RightMag_Right, number) and and if{ (>K:MAGNETO2_BOTH) }

    (A:ELECTRICAL MASTER BATTERY,bool)
    if{
    (L:MB_On_Init,enum) 0 == if{ 1 (>L:XMLSND10,bool) 1 (>L:MB_On_Init,enum) }
    (L:MB_On_Init,enum) 1 == if{ 2 (>L:XMLSND11,bool) }
    }
    (A:ELECTRICAL MASTER BATTERY,bool) ! (L:MB_On_Init,enum) 1 == and
    if{ 3 (>L:XMLSND11,bool) 1 (>L:XMLSND12,bool) 0 (>L:MB_On_Init,enum) }

    (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 > (A:ELECTRICAL MASTER BATTERY,bool) and
    if{
    (L:Avionics_On_Init,enum) 0 == if{ 1 (>L:XMLSND13,bool) 1 (>L:Avionics_On_Init,enum) }
    (L:Avionics_On_Init,enum) 1 == if{ 2 (>L:XMLSND14,bool) }
    }
    (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 ==
    (A:ELECTRICAL MASTER BATTERY,bool) !
    or
    (L:Avionics_On_Init,enum) 1 == and
    if{ 3 (>L:XMLSND14,bool) 1 (>L:XMLSND15,bool) 0 (>L:Avionics_On_Init,enum) }

    (L:Primer,enum) 0 != (A:ELECTRICAL MASTER BATTERY,bool) and if{  2 (>L:XMLSND16,bool) } els{  3 (>L:XMLSND16,bool) }

    (A:EXIT OPEN:0,percent) 0 &gt; (L:CabinLtsOvd, enum) 0 == and if{ 1 (>L:SwitchCabinLts, enum) }
    (A:EXIT OPEN:0,percent) 0 == (L:CabinLtsOvd, enum) 0 == and if{ 0 (>L:SwitchCabinLts, enum) }

    (A:BRAKE PARKING POSITION,percent) 0 &gt;
    if{ 1 (>K:FREEZE_LATITUDE_LONGITUDE_SET) 1 (>K:FREEZE_ATTITUDE_SET) }
    els{ 0 (>K:FREEZE_LATITUDE_LONGITUDE_SET) 0 (>K:FREEZE_ATTITUDE_SET) }

    (L:SND_INVC,bool) !
    (L:SND_MUTE,bool) or
    (L:SND_PAUSE,bool) or
    if{
    1 (>L:SND_GLOBALMUTE,bool)
    }

    els{
    0 (>L:SND_GLOBALMUTE,bool)
    }

    (A:ELECTRICAL MAIN BUS VOLTAGE, volts) 5 &gt; sp0
    (L:SwitchFLTLts,enum) l0 * (>L:SwitchFLTLtsON,enum)
    (L:SwitchPNLLts,enum) l0 * (>L:SwitchPNLLtsON,enum)
    (L:SwitchEngLts,enum) l0 * (>L:SwitchEngLtsON,enum)
    (L:SwitchRadioLts,bool) l0 * (>L:SwitchRadioLtsON,bool)

    <!-- CHECK IN THE DME.XML FOR THESE -> Fuel Flow and CHT (L:vars) -->
  </Update>
  <Macro Name="AP_Click">
    1 (&gt;L:XMLSND2,enum)
  </Macro>
  <Keys>
    <On Event="AP_MASTER">@AP_Click</On>
  </Keys>
</Gauge>
 
Last edited:
Dear Fr. Leaming

Thank you for this instructional code; as always, I learned something new from you.
Kindest regards,
Sergio.
:)
 
Back
Top