Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Please allow me to ask another Question regarding lua Scripting.

In my Script i want to determine, which Key on the Keyboard is pressed.
Let's say for the Keyboard Letter S. I want to do the Following.
If Key S is pressed then
     Do something
else
     If Key S is released then
            Do something else
     end
end

I know about the Key Assignments in the FSUIPC Menu. But i need to do some individual Things when a Key is pressed or released.
Is it possible, to handle the Keypresses in a lua Script? I know, that i can simulate Keypresses with the ipc.keypress Command. But i need to read,
which Key is pressed. Is there a similar Command available to do this Task?

Thanks in Advance for your Help.
Joachim
 

Posted

You don't do things like that really...
There are two choices:
   - capture the key press/release event using event.key. The lua script needs to be running to do this - such scripts are usually auto-started,
   - have two lua scripts, and assign one to be called/ran on the key press, and the other to be ran on the key release

Using events is the preferred method and will be quicker than having two separate scripts,

  • 1 month later...
Posted

If you really want to read a button state you can do it like this:

 

Button_C_Mask = ipc.buttons("C")
if logic.And(Button_C_Mask, 0x8000000) == 0x8000000 then	

 

Karl

Posted
1 hour ago, kaha said:

If you really want to read a button state you can do it like this:

Button_C_Mask = ipc.buttons("C")
if logic.And(Button_C_Mask, 0x8000000) == 0x8000000 then	

Its the state of a key he wants to read, not a button.

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.