ark1320 Posted June 19, 2020 Report Posted June 19, 2020 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
Pete Dowson Posted June 19, 2020 Report Posted June 19, 2020 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
ark1320 Posted June 19, 2020 Author Report Posted June 19, 2020 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now