Closed davidlav closed 3 years ago
You can run scripts using the built in jinja2 engine. You can either code the script directly into the json file or link to a separate file, the latter one is recommended. Linking to a file: https://github.com/maartentamboer/X-Touch-Mini-FS2020/blob/main/Configurations/config_default.json#L16 Example script files: https://github.com/maartentamboer/X-Touch-Mini-FS2020/tree/main/Configurations/Functions/Generic
The functions that you can call in a script can be found in the ConditionalRunner
class. This includes setting / getting simvars, getting mobiflight vars and triggering events.
For more information about the syntax for if and else see https://jinja.palletsprojects.com/en/3.0.x/templates/
Oh okay, so you can't just pass in RPN scripts like the above? You've got to rewrite them in this kind of domain-specific language you've got? That's not a critique, I just want to make sure I understand this correctly.
That's correct
Is there any way to interact with local variables? In the example I gave above, you manipulate the Wing/Engine Anti-ice in the WT CJ4 with the L vars DEICE_Airframe_1
and DEICE_Airframe_2
(pictured below).
This is something that's possible in Axis and Ohs, is it possible with X-Touch-Mini-FS2020 as well?
Nevermind, someone in the Working Title Discord advised me that L vars can be accessed from custom Mobiflight events. I think this solves me problem.
Just to close this out, the answer to my question is a qualified yes, insofar as they have the Mobilflight WASM module installed and the RPN script is either an existing Mobiflight event (i.e. one found on HubHop) or---if the user wants to run a custom RPN script---must be added to their \Community\mobiflight-event-module\modules\events.user.txt
file.
Is it possible to run a script, rather than an event, when a button is pressed? For example, this is how you toggle the Wing/Engine Anti-ice in the CJ4.
(A:STRUCTURAL DEICE SWITCH, Bool) 0 == if{ 1 (>L:DEICE_Airframe_1, bool) 1 (>L:DEICE_Airframe_2, bool) 1 (>K:TOGGLE_STRUCTURAL_DEICE) } els{ 0 (>L:DEICE_Airframe_1, bool) 0 (>L:DEICE_Airframe_2, bool) 0 (>K:TOGGLE_STRUCTURAL_DEICE) }
Can something like this be done?