Jump to content
The simFlight Network Forums
guenseli

Tutorial: how to get LUA Vars or commands out of FS

Recommended Posts

Sorry Simone,

I have deleted the link and replaced it by "llok at Updates and goodies section" here in this forum...

I'm sure, you will find it :mrgreen:

Share this post


Link to post
Share on other sites

And Simone,

would be very nice, you ill keep this thread clear of specific LUA questions...

feel free to open a new post in Petes forum...

There will your question will be found easier...

Share this post


Link to post
Share on other sites

Because of several questions I have decided to write a little tutorial for this people which want to assign their custom key commands via FSUIPC using LVARs or just the logging.

Hi, I am new to this, so please bear with me...

I would like to detect when a specific "L" variable in FSX changes value

from 0 to 1 and then issue a keypress.

I know how to issue a key press when a joystick button is pushed

and I have read that I can read Lvars using a LUA IPC command,

so I suspect that what I want to do is possible.

I need someone to confirm that this is indeed possible and point

me to a tutorial on how to construct the needed pieces and

how to string them together into a working solution..

I have the patience to try a few things, but am stuck at the very beginning...

Edit: after reading your tutorials and examples, I've actually got it working!

Little LUA program:

while 1 do
enter=ipc.readLvar("L:XXXXX")
if enter ~= 0 then
ipc.keypress(113,32)
end
ipc.sleep(100)
end

and an AUTO entry in FSUIPC.ini to start the lua program

for this aircraft.. and it works!

Thanks for all the great info here and the brilliant

FSUIPC program. :D

Share this post


Link to post
Share on other sites

Oh wow!

Old as this thread is, I've only just read it (or tried to :oops: )

It's brilliant. Only wish I had the 'know how' and aptitude to impliment this stuff.

I only recently aquired some saitek panels (yuk! But hindsight is a wonderful thing :huh: ), for which some of this stuff can actually make work.

This is just a 'pre-emptive' thanks to the contibutors (and Pete of course) in case I just happen to be able to make use of it.

So, Thanks all!

Share this post


Link to post
Share on other sites

Now left me a question, how could I detect when these FSUIPC variable was modified? What I mean is, like FSUIPC can log an action in a case such as variable L: EmbLandLt = 0, referring to the Landing Light, yet use FSUIPC as I could in my program and do the same?

I'm a bit confused by your question.

If you want to see when L:Vars change, there's a Lua plug-in provided in the Examples installed by FSUIPC which logs L:Vars and their changes in real-time to an overlain Lua display window. It's called "log lvars.lua".

If you are instead referring to internal FS values, not local gauge variables, then you can monitor the relevant offsets using the FSUIPC monitoring facilities in the Logging section. You'll need to find the appropriate offsets and their types from the documents provided in the FSUIPC SDK. For instance the lights are all individual bits in a word (U16) at offset 0D0C.

Regards

Pete

Share this post


Link to post
Share on other sites

Hi Pete,

could this work with the flight1tech g1000 training software, which uses external switches on hardware (no visible panel).  If I flip a switch on the hardware while in fsx, could I get a logging or lua variable?

 

thanks, 

John

Share this post


Link to post
Share on other sites
Just now, jmg225 said:

could this work with the flight1tech g1000 training software, which uses external switches on hardware (no visible panel).  If I flip a switch on the hardware while in fsx, could I get a logging or lua variable?

Sorry, I've no idea what you want to do. If the switches are seen by FS and FSUIPC then of course you can assign them to various things, but what do me mean "get a logging or lua variable"? "Get" what to where and for what?

Best to post support questions to the Support Forum. This subforum is really a reference section and I rarely look here.

Pete

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.