Closed jeremy-collette closed 3 years ago
set and get _simvar_value value will only work on existing simvars which can be found here: https://github.com/odwdinc/Python-SimConnect/blob/master/SimConnect/RequestList.py
I'm guessing you want to use SWAP_COM as a temp variable?
Ah I see... Yes that's correct. Is there any way to support defining new simvars? It looks like you are already be defining vars in _deff_test?
If not, is there any way to store state in the key bindings?
You could try to just create a new variable in the data object. The data object is of the type ConditionalRunner https://github.com/maartentamboer/X-Touch-Mini-FS2020/blob/main/conditionalrunner.py#L9
Since Python is fairly flexible regarding the handling of objects you could probably add a variable to that conditionalrunner instance.
So perhaps something like data.my_var_name = 1.0
could work
Otherwise I will implement a new feature which will enable a global variable storage
I understand. I will try setting a value on the data object.
Yes, something like "set_localvar_value" would be a nice feature :-)
I tried setting a variable directly on the data member but it did not work (Python error). Looks like a local/global variable set/get feature might be required for more complex behaviors.
Sounds like a good feature, I'll hopefully have some time next weekend to implement this
@maartentamboer If you're looking for contributors, I'd be happy to take a stab at this. Seems like a simple method on the ConditionalRunner should handle it. Otherwise good luck & thanks!
Contributors are always welcome 👍 feel free to make a PR anytime PR https://github.com/maartentamboer/X-Touch-Mini-FS2020/pull/23 has support for this feature. I will close this issue once a new release is made.
I've updated your proposal from the opening post so it works in this new feature.
{
"index": 16,
"event_press": {
"type": "condition",
"event": [ "{% if data.get_global_variable('SWAP_COM') == true %}",
"{{ data.print('COM_STBY_RADIO_SWAP') }}",
"{{ data.trigger_event('COM_STBY_RADIO_SWAP', 1.0) }}",
"{{ data.set_global_variable('SWAP_COM', false) }}",
"{% else %}",
"{{ data.print('COM2_RADIO_SWAP') }}",
"{{ data.trigger_event('COM2_RADIO_SWAP', 1.0) }}",
"{{ data.set_global_variable('SWAP_COM', true) }}",
"{% endif %}" ],
"description": "Swap COM"
}
data.get_global_variable(key)
: Get a global variable value based on a key
data.set_global_variable(key, value)
: Set a global variable to a value
data.print(data)
: Print something in the console
Fixed in the latest release https://github.com/maartentamboer/X-Touch-Mini-FS2020/releases/tag/v1.1.0
Hello, is setting simvar values supported in event_press conditions?
I'm trying to create a COM swap button as follows:
But set_simvar_value does not seem to work. Any ideas?