Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hey John,

is it possible, to simulate a Press of a Joystick with Lua Code?
I want to simulate this Button Press if a special Condition is fulfilled.

Thanks in Advance
Joachim

Posted
5 hours ago, Airbuspilot said:

is it possible, to simulate a Press of a Joystick with Lua Code?
I want to simulate this Button Press if a special Condition is fulfilled.

In general yes (see the FSUIPC Lua Event library), but it depends on if the special condition can be detected with code; that is, are the necessary simvars (variables) associated with the special condition available?  I think it would help John give you the best answer if you would provide him with some information on the nature of the special condition you are talking about.

Al

Posted
13 hours ago, Airbuspilot said:

is it possible, to simulate a Press of a Joystick with Lua Code?

Generally not, only for virtual buttons - see the ipc.btnPress, ipc.btnRelease and ipc.btnToggle lua functions.

But why do you want to do this? Can you not just simulate the action that the button press performs when your condition is met, rather than the button press itself?

John

Posted
8 hours ago, ark1320 said:

In general yes (see the FSUIPC Lua Event library), but it depends on if the special condition can be detected with code; that is, are the necessary simvars (variables) associated with the special condition available?  I think it would help John give you the best answer if you would provide him with some information on the nature of the special condition you are talking about.

I have several Planes, that were controlled and directed by a File named FlightLog.lua
For every Plane there is a separate File, that contains the SimVars and Lvars of this Plane. This File is also named FlightLog but extended with the ID of this Aircraft, i.E. FlightLog.DAIJB
The Reason for this is to save my Flights in a MS Access Database. Before starting a Flight, i file FlightPlans, Fuel Amounts, PayLoad, etc. in this DB. Once everything is done, i rename
the File FlightLog.DAIJB to FlightLog.lua and copy it from the Scripts Folder to the FSUIPC Folder. Because of that, i have all Variables according to the used Plane in the FlightLog.lua and 
can assure, that the Variables are available at the Runtime. For each of this Aircraft there are different Variables, that will be used, to trigger the Condition where the simulated Joystick Button should be pressed.  

Posted
19 minutes ago, John Dowson said:

Generally not, only for virtual buttons - see the ipc.btnPress, ipc.btnRelease and ipc.btnToggle lua functions.

But why do you want to do this? Can you not just simulate the action that the button press performs when your condition is met, rather than the button press itself?

In general i could do that. But for each A/C i have a different FlightLog.lua and an according Window.lua
I start them with one Joystick Button on the Press and Release Event. My Aim is now, to open a second Window if necessary for the used Plane.
This could be named Window2.lua and could be assigned to a separate Joystick Button in the FSUIPC Button Assignments. And so i want to simulate
the Button Press with Lua Code, if my Condition is fulfilled. I want to do it this Way to hold the FlightLog itself as small as possible for Maintenance Reasons.
I know, i could fill all the Window Texts in the FlightLog, but i would prefer the separate File Solution for each Window.lua, if possible

Joachim 

Posted
16 minutes ago, Airbuspilot said:

This could be named Window2.lua and could be assigned to a separate Joystick Button in the FSUIPC Button Assignments. And so i want to simulate
the Button Press with Lua Code, if my Condition is fulfilled.

If your condition is filled, you can just call ipc.runlua("Window2.lua"), no?

Otherwise, use virtual buttons which can be "simulated".

Posted
1 hour ago, John Dowson said:

If your condition is filled, you can just call ipc.runlua("Window2.lua"), no?

I have to apologize that i didn't remember the runlua Function. It is indeed so easy.
Sorry, that i made unnecessary Work on your Side.

Posted
6 hours ago, John Dowson said:

Can you not just trigger the action that the button press would perform?

Sorry for any confusion on my part, that is what I thought was the intention from the start.

Al

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
×
×
  • Create New...

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.