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

Using state.cfg to save switch positions?

Messages
24
Country
us-colorado
Can someone give me a basic idea on how this works? I've discovered you can use the state.cfg file in conjunction with the systems.cfg to save the state of switches when you exit the aircraft. Is there more to it than that? Because I can set the switches and see the state is being written to the state.cfg file when I exit. But when I reload the plane, the switches are back to their default on positions.

What I'm working on, is trying to set the learjet 35a fuel switches to off when the plane loads. These are defined as:
GENERIC_LEAR_FUEL_MAINPUMP1_1=0
GENERIC_LEAR_FUEL_MAINPUMP2_1=0

In the state.cfg

And I have them in the systems.cfg as:
LocalVar.55 = GENERIC_LEAR_FUEL_MAINPUMP1_1
LocalVar.56 = GENERIC_LEAR_FUEL_MAINPUMP2_1
and
LocalVarDefault.55 = 0
LocalVarDefault.56 = 0

Is there another place these need to be set, or some other code that I'm not aware of?
 
I think your index should start at 1 in the systems.cfg, that might fix it.
LocalVar.1 = GENERIC_LEAR_FUEL_MAINPUMP1_1
LocalVar.2 = GENERIC_LEAR_FUEL_MAINPUMP2_1
LocalVarDefault.1 = 0
LocalVarDefault.2 = 0

That is assumed your variables are correct.
Since you want to set fuel pumps presumably in a cold and dark state I'd alternatively look into the apron.flt and edit one of the following sections

[Engine Parameters.1.0]
ThrottleLeverPct=0.0
PropellerLeverPct=1
MixtureLeverPct=1
Pct Engine RPM=0
MaxReachedEngineRPM=2454.7394303494743
LeftMagneto=False
RightMagneto=False
GeneratorSwitch=False
FuelValveOpen=False
CowlFlapPct=0
FuelPumpSwitch=False
CarbHeat/DeiceSwitch=False
EngineMasterSwitch=False

[FuelSystem.0]
Tank.1=1
Tank.2=1
Tank.3=1
Valve.1=False
Pump.1=1
Pump.2=1
 
Thanks, I'll give that a go and see what happens. But I wonder why I would have to start from 1? There's already a number of switches being set, so the reason I have these at 55 and 56 is simply adding them to end of the current list. And of course if I do that, then I'd have to renumber all those 50+ other switches. That doesn't make sense to me.
 
Ah ok. I don't know the Learjet, so...
Anyway, I would check the flight_model.cfg wether it has a [fuel] or [fuel_system] section, identify the pumps and do the settings accordingly in the apron.cfg.
You may also need those L:Vars in the systems.cfg, depending on how they programmed their behaviour file.
 
This function is not complicated to implement but requires to respect some rules.
1) The variables to be saved are defined in the system.cfg file and a default value is set after each new declaration so that when the STATE.cfg file does not exist it can create the file and initialize these variables.
2) Depending on where the aircraft appears (runway, apron, hangar, etc.) it is also necessary to define as Mathias said the appropriate variables so that the appropriate FLT file can load correctly the aircraft in the required state.
3) To close the flight and in order for the variables to be backuped, it is imperative:
a) that the plane is properly landed, stopped and
b) that a MSFS window signifying the end of the flight appears which allows the user to return to the main menu.

If you do not do this and exit your simulator by the cross icon in the upper right of the screen or by a CTRL+F4 the data will not be saved.
I use this principle to make the backups of our advanced mode on the Super Stearman since May and without any problems.

If the aircraft that you use has already some variables defined and backuped (1 => 54), you should define and increment the number attached to your variables (55, 56, etc)
 
This function is not complicated to implement but requires to respect some rules.
1) The variables to be saved are defined in the system.cfg file and a default value is set after each new declaration so that when the STATE.cfg file does not exist it can create the file and initialize these variables.
2) Depending on where the aircraft appears (runway, apron, hangar, etc.) it is also necessary to define as Mathias said the appropriate variables so that the appropriate FLT file can load correctly the aircraft in the required state.
3) To close the flight and in order for the variables to be backuped, it is imperative:
a) that the plane is properly landed, stopped and
b) that a MSFS window signifying the end of the flight appears which allows the user to return to the main menu.

If you do not do this and exit your simulator by the cross icon in the upper right of the screen or by a CTRL+F4 the data will not be saved.
I use this principle to make the backups of our advanced mode on the Super Stearman since May and without any problems.

If the aircraft that you use has already some variables defined and backuped (1 => 54), you should define and increment the number attached to your variables (55, 56, etc)
Ah ok. I don't know the Learjet, so...
Anyway, I would check the flight_model.cfg wether it has a [fuel] or [fuel_system] section, identify the pumps and do the settings accordingly in the apron.cfg.
You may also need those L:Vars in the systems.cfg, depending on how they programmed their behaviour file.
Thanks! I'll do more checking in the files and see what I can discover. I'm sure it's just a matter of understanding the rules and checking the other files you've mentioned. I'll mess around a little later and report back what I've accomplished.
 
Back
Top