MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
Abtzero
Posts: 22
I have a button that just increments a Mobiflight variable "SetMode".
When this variable is reaching 9 it is set to 0.

I also have a number of input actions with a singe rotary encoder, that will work if "SetMode" has a certain value.
So I can cycle through all possible modes with a single button and change values of the autopilot with a single encoder.
I made this for "blind" use in VR.
I cannot see, what will be changed, i.e. which value the variable has.
So I added sound output via FSUIPC lua scripts.
Thes scripts just contain a single command:
sound.play("NAV.wav", 3)
for example.
It tells me, which mode I have entered.
I created for each mode an output config with the choosen Sim Variable "Mobiflight Variable" and a pre-condition SetMode = something.

On the Display Tab I choose the type "Input Action" and set it "OnChange"
Now the Lua scripts only run once after Mobiflight is started (and SetMode has the correct value).
I cycle thru the modes and it is never triggered again.
The same when I use "OnPress / On Release" instead of "On Change".

Why is this? The value changes, but not when the pre-condition is met. In this moment it has the old value of the last time, the pre-condition was met.
Is this the reason, it does not work?

I tried different things, but nothing helped except this funny workaraound:

Instead of using "Mobiflight Variable" as recognized Sim variable, I used the Sim Connect Variable
Microsoft - Generic - Evironment - LOCAL TIME, to get a always changing value.
Set it to "OnChange" and it works!
But only when switching to the next mode - which is too late (Sound plays for the former mode).
I can handle this by setting the pre-condition SetMode value for the previous one. OK. Works, but feels a bit quirky.

I do not understand why it behvaves this way. Is this intented to work like this?
Would mean: "OnChange" is triggered, when the value of a Mobiflight variable differs from the value of the last time, the pre-condition is met?

Any other idea to get this working in a more elegant way?
2023-11-28 02:29
Avatar
DocMoebiuz
Moderator
From: EDSH, Germany
Posts: 1516
Hey, your use case sounds super interesting. Please join us on the Discord to interactively figure it out.

I think you should be able to use a MobiFlight variable and a Output Input Action... Just make sure that you are using "@" as value placeholder instead of the normal "$"
Because you are right: OnChange will only trigger if the value changes. so for some reason your value isn't and I can see that it could be because of $ vs @.
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - MSFS2020, FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2023-12-16 20:30
icon