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
Miguelito
Posts: 3
Hi!

Could somebody please give me an example, how to run a lua script which - for example - toggles the gear?!
How does the configuration in MobiFlight looks like, and what about the script? Do I need a *.lua or a *mcro file?
I have P3D V3 and FSUIPC 4.957.

Thank you very much!
2019-01-21 23:40
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

About a Lua script.... Here you find thousends of sites in the web. You can learn completly programming by manuals and youtube videos ! Simply google !
About Function in FSUIPC.... Just read "FSUIPC Manual for advanced Users.pdf. It´s included in your /P3D/Modules folder.

About Mobiflight:

You can fire a Lua script/macro via 2 ways.

1. Key Command or Joystickbutton
Here the Lua Code itself is just creat in FSUIPC and THERE you make a keybind and say for example " If Key "G" is pressed then execute Macro xyz."
You can also use a Joystickbutton instead of a Key in FSUIPC to fire a Macro/script.
Mobiflight now just "simulate" this Button/Key Action.
For Key use "KEY" as option in Input Config "typ" field.
For Joystick Button you can write FSUIPC (Offset 3340) to create "virtual buttons" or you use the VJOY PlugIn of Mobiflight to simmulate VJOY Button Presses.

2. Fire Commands directly via the new "LUA MACRO" Tool of Mobiflight.
Here you choose "LUA Macro" as TYP of Input .... There you can controll Macros directly !

EDIT : Also Check this ! https://www.mobiflight.com/forum/message/10232.html
Good Luck !
2019-01-22 14:45
Avatar
Miguelito
Posts: 3
Thanks a lot for your respond!
But, so far I did understand the theoretical way. Anyway, for some reason, I couldn't run a scipt til now.

Thats why I asked for a little "tutorial": Just one line for MobiFlight, and just one other (I guess) for the script.
(something like ipc.control(65570, 1), right??? And once again the question: *.lua or a *.mcro file?)

Thanks again!!!
2019-01-22 20:47
Avatar
Miguelito
Posts: 3
Ok, I figured it out!

The syntax in MF is
"Lua XY" in the field "Macro Name" (without quotes).
Value is "0".

A file named "XY.lua" has been placed in the "Modules"-folder. In my example the file contains just:
ipc.control(65570)

This will toggle the gear, if the MobiFlight-input is triggered.

My mistake was to write "XY" or "XY.lua" into the Macro Name field. Not a big deal, but syntax makes the difference! ;)
2019-01-22 21:57
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi again....

The Syntax for Mobiflight Side is explaned in the linked topic above.
Sorry i can´t give you a tutorial.... I just startup with that LUA Tool im Mobiflight myself and have not much experience.
Just Note... You explane the "script" system. You can also work with a Macro file (*.mcro )
In that case the syntax is different (also explaned in the linked topic) Use a ":" then to choose the Macro File and the included Macro inside.

About Lua Scripts.

I hope your general intention at the moment is testing ! .....
It makes no sense to fire a Script with a simple IPC controll.... Cause you can do it with Typ "EventID" direcly in Mobiflight.... So you need no difficult Script/Start logic here.

To see the basic technics for LUA Script i recommend to download the FSUIPC SDK from Pete Dowsons Webpage http://fsuipc.simflight.com/beta/FSUIPC_SDK.zip
This Include some Manuals and much more important it include "example files" .
These Files are commented by pete Dowson in the code.... So you "see" how it workes.

Finaly i recommend to download a good Scripting Editor. Myself i use "Notepad++" .... Its freeware.
scripting with a standard Editior is bad !
Good Luck !
2019-01-23 10:16
icon