maartentamboer / X-Touch-Mini-FS2020

Control FS2020 with a Behringer X-Touch Mini
https://dev-tty.nl/X-Touch-Mini-FS2020/
MIT License
57 stars 19 forks source link

Is it possible to run RPN scripts? #86

Closed davidlav closed 2 years ago

davidlav commented 2 years ago

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?

maartentamboer commented 2 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/

davidlav commented 2 years ago

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.

maartentamboer commented 2 years ago

That's correct

davidlav commented 2 years ago

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

image

This is something that's possible in Axis and Ohs, is it possible with X-Touch-Mini-FS2020 as well?

davidlav commented 2 years ago

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.

davidlav commented 2 years ago

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.