Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Can an instruction like event.key() be used inside a processing loop to act like an interrupt in other languages?

I would like to detect a key stroke while a while true do loop is processing, and after the function associated with event.key() has finished, I want the processing loop to continue.

Thanks,

Al

Posted
1 hour ago, ark1320 said:

Can an instruction like event.key() be used inside a processing loop to act like an interrupt in other languages?

No, the Lua event library functions provide a way to call a function in a previously dormant plug-in, one just waiting for such an event.

If you want to check for key presses in an active loop use the Lua flag system. Assign that key press to set the flag (LuaSet <plug-in name>  with flag nimberas parameter) and test for it by ipc.testflag in your loop (or of course LuaToggle).

Things like button presses (on scanned joysticks) can be tested without such complication, but you can't expect FSUIPC to maintain a note of every possible key press in case somethnig tests for it. And even if it did, when does it clear it down? How many running plug-ins might be waiting for it -- but not able to test immediately because being busy?

The short answer, of course, in that there's no "interrupt system" available in Lua. That would really need multiple threads within the multiple thread system which are the individual plug-ins!

Pete

 

Posted
32 minutes ago, Pete Dowson said:

No, the Lua event library functions provide a way to call a function in a previously dormant plug-in, one just waiting for such an event.

If you want to check for key presses in an active loop use the Lua flag system. Assign that key press to set the flag (LuaSet <plug-in name>  with flag nimberas parameter) and test for it by ipc.testflag in your loop (or of course LuaToggle).

Things like button presses (on scanned joysticks) can be tested without such complication, but you can't expect FSUIPC to maintain a note of every possible key press in case somethnig tests for it. And even if it did, when does it clear it down? How many running plug-ins might be waiting for it -- but not able to test immediately because being busy?

The short answer, of course, in that there's no "interrupt system" available in Lua. That would really need multiple threads within the multiple thread system which are the individual plug-ins!

Pete

 

OK, I understand,  thanks very much for the feedback!

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.