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
sisoffi
Posts: 91
Hi at all,
Im tryng to configure some Lua Macro directly on the Action Type.
My macro was correctly detected through fsuipc 5 in prepar3d v4 and the macro file was generated correctly inside the fsuipc folder.
Now I'm going to configure a button, this is an example in the .MCO file:

[Macros]
1 = MCP_SPD = RX40000044,3
.....

put in Action Type the Macro Name MCP_SPD
the value 1 is the macro on in an action while release 0 in off?

I can't find tutorials but unfortunately it doesn't work.

many thanks!
2019-04-22 21:50
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

At first get sure your Macro work correctly.
For that simply set the macro within FSUIPC to a key or Joy Button..... Test it if it work fine.

If Yes you have 2 ways.....

1. You can execute the "indicator" that you use in FSUIPC for the macro via Mobiflight. For example you use KEY SEND if you use a Key.... OR You can fire a virtual Joystickbutton via offset 3340 .... OR you can use "VJoy" Plugin to simulate a Joy button. ... Finaly your Macro is controlled via FSUIPC.... Mobi here just simulate the Input that start it.

2. You use LUA PlugIn in Mobiflight to directly controll the Macro.
Check this..... https://www.mobiflight.com/forum/message/10232.html for detailed Syntax !

Appology there is no real guide exist until now.... Its on the ToDo but i not find time a.t.m.
Good Luck !
2019-04-23 13:42
Avatar
sisoffi
Posts: 91
Hi,
thank you for your reply.
The sintax was incorrectly.

Now work very well.

thanks
2019-04-23 14:10
Avatar
Floh124
From: between EDDL and EDDK, Germany
Posts: 10
Hello,
I hope it correct to adress my question here:

With this "new" function (LUA Macro Setting) I'm planning to do all my input functions for the QW Sim B787 and I already figured out how to "do" things with separate LUA files (e.g. Batt_On.lua or Exp_pwr_on.lua).

It works quite well so far that I can toggle functions with pushbutton (momentary) switches, where I see no problem on binding and configuring them to my demands. But for many functions I'm also using latched switches and with them I want to use the "on release" and "on push" function separate (e.g. Nav Light). Do I need to creat two lua files (e.g. Nav_light_on.lua and Nav_light_off.lua)? I know that I can use the same LUA file for toggling, but I like to really bind the function to the switch position. That means, if the switch is in the "up" position the Nav-Light should be on... (I will raise also a question about checking switch position separately)

In conjuction with this question, I like to know, what this value field does in the LUA Macro Setting Tab. Can I use this value inside the LUA file and if, is it possible that some one explain it to me? If not, this "two lua file way" would be the only chance, or wouldn't it?

Best regards
Florian
2021-01-06 14:36
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Nice.... I see you know what your talking about !

Related to your other topic ( sync of switches) you figure out the problem of "toggle" Inputs. I agree. Sending a "if $=1 then 0 else 1" is nice for a momentary button.... But latching switches MUST have a clear state..... Toggle by a latching switch is "sh**t"

I not have eperience by those Lua Stuff (Here Sebastian is your man or some advanced users in our DISCORD Group)
Your IDea is correct.
The Lua Macro Tool ( as i know) allow us to send in the Value Field a "Parameter" that is send to FSUIPC.
So it should be possible to "recive" this value within the Lua Macro Code.
Then you can say something like....
IF "recived" Value = 1 THEN execute the Event/action to put the Switch to ON .... ELSE.... Put the Switch to OFF in the Sim"

Badly i can not give you a code example.... Please ask here the advanced Users.


Alternate:
Lua Macro that is run in a LOOP and controll Offsets.
Instead of running a single Process ( A Macro that is executed by the LUA Tool of Mobiflight and run only one single time) there exist a logic with a "loop"
Means a Lua Code that run in FSUIPC all time while you use the aircraft.
this code "observe" a list of Offsets you define. And Mobiflight simply write this Offsets.

For example:
Your Latching Switch write Offset 66C0 to 1 if its ON (Press) and to 0 if it´s OFF (Release).
The Lua code say.... "Observe Offset 66C0 ... If there is a change in that offset run the follow code 1 time..... CHECK the Value of 66C0.... IF 1 then execute A if 0 Execute B "
Good Luck !
2021-01-07 17:23
Avatar
Floh124
From: between EDDL and EDDK, Germany
Posts: 10
Hi, (please excuse my delay in replying)

I already use the LUA (fire) function on my QW787. It works quite well but I use a single, separate LUA File for every input that I need (on the 787 I use 13 Lua Inputs). I think about combining them in one single macro, as you described it (and I'm also thinking of adding all planes LUA in this way with a airfile readout for selecting separate Loops / but as I'm a beginner in LUA scripting I'm happy if I get all my usual planes running/working. This automatic things are then the plus on top.

So is someone here, who can explain this LUA Value function? (I'm also absolutely new on this discord things, so I try also to get in this later on)

Best regards
Floh
2021-01-15 21:02
Avatar
Floh124
From: between EDDL and EDDK, Germany
Posts: 10
Hello,
i fifured out how it works with this value parameter. You can read it inside the LUA file and with this use it for separate functions. With this I would be able to create on LUA file for all inputs, wouldn't I? it does sound logical to me, that with this I can create one LUA file for all inputs, even for different airplanes by assigning unique numbers to each function and with this having one big LUa file for all inputs.

I attach a example how I use it actually:
if ipcPARAM == 1 then
ipc.control(66587, 72487)
end

if ipcPARAM == 0 then
ipc.control(66587, 72486)
ipc.control(66587, 72486)
end

And if I would also create one big LUA file for all outputs (with the "aircraft readout feature") I could control and also get all the outputs of all of my different airplanes with just 2 LUA files or am I wrong? And is this the "best" way? I'm using separate airplanes (Airbus, Bombardier, BAe and Boeing) with a pretty universal control panel... I learned already (and asked pizman82) that I have to manually load the MCC files for each separate plane, but to have only to LUA files would make it more comfortable.


(This is just the first layout. I found out, that the "Batt" and "Avi" switches are more or less useless on my airplanes and my setup)

Best regards
Florian
Should I start a new thread for my panel in the "projects" channel to also allow other users to "take part" on it?
2021-01-19 15:19
icon