Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Variables - init #57

Closed
SQLSammy opened this issue Mar 21, 2021 · 11 comments
Closed

Global Variables - init #57

SQLSammy opened this issue Mar 21, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@SQLSammy
Copy link

Is it possible to add an init section for every aircraft
running when aircraft/flight load to

  • initialize global variables
  • or aircraft setting, f.e. predefined values for cockpit lights, flashlight depending on time
  • or define a random set of settings which are random set or not set (to make pre flight checks of switches more realistic)
@SQLSammy
Copy link
Author

After thinking about it, the last two points are a problem,
because sometime we load the tool later in flight. Then it would
be needed to detect a preflight load in menu vs. later load in aircraft.

@maartentamboer
Copy link
Owner

The init for global variables is definitely something I will add to this. Because I have also run into the issue of a variable initially being None.
Regarding the aircraft setting, that is a bit challenging because of load times. Basically when you select the aircraft and click fly the simconnect API already notifies which aircraft is selected, but the sim is still loading. So any changes you make are probably overwritten.

@maartentamboer maartentamboer added the enhancement New feature or request label Mar 21, 2021
@SQLSammy
Copy link
Author

The "none" problem was my initial intention for this request

@maartentamboer
Copy link
Owner

I have 2 options in mind for this. Option 1 enables you to add the variables directly in the config file. Option 2 enables you to call a jinja2 script file.

Option 1 (part of the config_a320.json):

"initialization": {
    "global_variables": [
      {
        "name": "MFD_RANGE",
        "value": 10
      },
      {
        "name": "OTHER_VAR",
        "value": false
      }
    ],
  }

Option 2 (part of the config_a320.json):

"initialization": {
    "on_config_load": "Functions/A320/init.jinja2"
  }

Functions/A320/init.jinja2:

{{ data.set_global_variable('MFD_RANGE', 10) }}
{{ data.set_global_variable('OTHER_VAR', False) }}

Any preference?

@SQLSammy
Copy link
Author

I wouldnt split the config to too many files, makes it more complex to share

@FraSie
Copy link

FraSie commented Mar 22, 2021

I would prefer to have it in one file.
I also experiment with assigning the initialization to a button, e.g. pressing button 32 means initialize (so I have the control. In my experiments I sometimes have the problem, that the state of the airplane differs from the state in the python. Initializing would have the advantage, to align them...)

@SQLSammy
Copy link
Author

Great idea, button 32 long press = init aircraft,
but this can be done already

@FraSie
Copy link

FraSie commented Mar 22, 2021

...ok, you are right, this can be done already. I think it would be good implement it in a way, that the initialization can be evoked flexible: by an event, like "on_config_load" in option 2 (if I understand it right), or by pressing a button or someting else.
It is good to have the initialization in one single block (function, method, ...I am not a python specialist).

@reimuell
Copy link

Many of my plane settings habe common rotary/buttons. Is it possible to have a common config file and only plane specific values in other files (other languages have something like a perform) . I'm not talking about global values.
Yes I understand the problem of aircraft load time, we would have to wait until the flight/plan is really loaded.
thx

@maartentamboer
Copy link
Owner

Many of my plane settings habe common rotary/buttons. Is it possible to have a common config file and only plane specific values in other files (other languages have something like a perform) . I'm not talking about global values.
Yes I understand the problem of aircraft load time, we would have to wait until the flight/plan is really loaded.
thx

I've made a seperate issue to track this request regarding the common config file. It is quite a big change so It's probably not coming too soon

@maartentamboer
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants