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

Is it possible to run RPN scripts? #86

Closed
davidlav opened this issue Aug 20, 2021 · 6 comments
Closed

Is it possible to run RPN scripts? #86

davidlav opened this issue Aug 20, 2021 · 6 comments
Labels
question Further information is requested

Comments

@davidlav
Copy link

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
Copy link
Owner

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/

@maartentamboer maartentamboer added the question Further information is requested label Aug 20, 2021
@davidlav
Copy link
Author

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
Copy link
Owner

That's correct

@davidlav
Copy link
Author

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
Copy link
Author

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
Copy link
Author

davidlav commented Sep 2, 2021

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.

@davidlav davidlav closed this as completed Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants