hkhoanguyen Posted October 5, 2020 Report Posted October 5, 2020 Hello, By adding event.key in my lua script, the GSX select option by keyboard number from 1-9 (called by ipc.keypress) does not work anymore, do you have any idea why ? function aftertakeoff() ipc.log("test") end event.key(191, 8, 'aftertakeoff') Thanks
John Dowson Posted October 5, 2020 Report Posted October 5, 2020 What sim and version of FSUIPC are you using? You could try activating key press logging, to see what VK keycode is logged when you press your key. Key code 191 is Numpad 7 (with NUMLOCK ON) according to the manual, BUT these keys vary from keyboard to keyboard. On my keyboard, Numpad 7 with NUMLOCK ON is vk=103. 1 hour ago, hkhoanguyen said: does not work anymore So it previously worked? What has changed? Maybe your NUMLOCK is OFF?
John Dowson Posted October 5, 2020 Report Posted October 5, 2020 Btw, is your lua even running? i.e. are you starting in somehow (e.g on a button press) or have you added it to your [Auto] section?
hkhoanguyen Posted October 5, 2020 Author Report Posted October 5, 2020 20 hours ago, John Dowson said: Btw, is your lua even running? i.e. are you starting in somehow (e.g on a button press) or have you added it to your [Auto] section? Hi John, Thank you for your reply, My lua running, it worked normally for the numer 1-9 of GSX Select Option, only until I added event.key then ipc.keypress stopped working the loop function reads for anti collision light ON and the Ground Call switch on 737 overhead is pushed, then start GSX push back, just when I added event.key to run another function then my push back GSX keypress is not working anymore (that means the GSX Menu is opened but number pressed is not working) Thanks John!
John Dowson Posted October 5, 2020 Report Posted October 5, 2020 Can you please let me know what sim and what version of FSUIPC you are using (or show me your FSUIPC log file) 15 minutes ago, hkhoanguyen said: just when I added event.key to run another function then my push back GSX keypress is not working anymore (that means the GSX Menu is opened but number pressed is not working) Ok, so different from your original post....! You are saying that your script worked, but when you added the extra event.key call + function then it stopped working - correct? Does your aftertakeoff() function get called when you press the '191' key? Is you loop function still getting called by the timer? Have you tried activating logging for lua plugins?
hkhoanguyen Posted October 5, 2020 Author Report Posted October 5, 2020 1 hour ago, John Dowson said: Can you please let me know what sim and what version of FSUIPC you are using (or show me your FSUIPC log file) Ok, so different from your original post....! You are saying that your script worked, but when you added the extra event.key call + function then it stopped working - correct? Does your aftertakeoff() function get called when you press the '191' key? Is you loop function still getting called by the timer? Have you tried activating logging for lua plugins? my sim is P3D v5 and FSUIPC 6 Sorry if i was not clear enough, Before adding event.key, my ipc.keypress worked normally Yes my loop function is still getting called by the timer, and yes my aftertakeoff function also gets called when I press 191, everything works except the ipc.keypress stops working when I add event.key line
John Dowson Posted October 5, 2020 Report Posted October 5, 2020 3 minutes ago, hkhoanguyen said: my sim is P3D v5 and FSUIPC 6 But what version of FSUIPC6? If you are not using the latest (v6.0.10) can you please update and retry. There was an update for a bug in event.key that was fixed in that version. For support requests, either specify the exact version you are using or, better still, attach you log file so I can see what version you have + other information that is useful to me in helping you.
hkhoanguyen Posted October 5, 2020 Author Report Posted October 5, 2020 4 minutes ago, John Dowson said: But what version of FSUIPC6? If you are not using the latest (v6.0.10) can you please update and retry. There was an update for a bug in event.key that was fixed in that version. For support requests, either specify the exact version you are using or, better still, attach you log file so I can see what version you have + other information that is useful to me in helping you. I didn't know that thers is a newer version of FSUIPC, mine is FSUIPC6, Version 6.0.9 I will update it to see, Thanks John
hkhoanguyen Posted October 6, 2020 Author Report Posted October 6, 2020 22 hours ago, John Dowson said: But what version of FSUIPC6? If you are not using the latest (v6.0.10) can you please update and retry. There was an update for a bug in event.key that was fixed in that version. For support requests, either specify the exact version you are using or, better still, attach you log file so I can see what version you have + other information that is useful to me in helping you. Hi John, It is exactly that i was not using the latest version, it is fixed now. I have one more question, do you have any idea of how to prevent the initial load of function when using event.offset ? I just dont want to run my function when the lua is loaded, thanks! Except of using boolean global variable, I can"t think of any other way.
John Dowson Posted October 6, 2020 Report Posted October 6, 2020 16 minutes ago, hkhoanguyen said: how to prevent the initial load of function when using event.offset ? Presume that you mean the initial call of the function, but no, this cannot be prevented. However, you can handle in your function by returning straight away if its on the first/initial call. You can determine this by using a global variable, and checking/changing the initial value in the function, exiting if it is the first call. For most use cases, this initial call is needed to initialise/sync the offset value in the script with the actual offset value.
hkhoanguyen Posted October 7, 2020 Author Report Posted October 7, 2020 19 hours ago, John Dowson said: Presume that you mean the initial call of the function, but no, this cannot be prevented. However, you can handle in your function by returning straight away if its on the first/initial call. You can determine this by using a global variable, and checking/changing the initial value in the function, exiting if it is the first call. For most use cases, this initial call is needed to initialise/sync the offset value in the script with the actual offset value. Thanks John, I implemented it with a global boolean variable, I'm thinking of switching my code from lua to C#, do you know whether in c# with FSUIPC DLL there are also the event.offset or event.timer or event.lvar ? thanks @John Dowson @Paul Henty
John Dowson Posted October 7, 2020 Report Posted October 7, 2020 1 hour ago, hkhoanguyen said: do you know whether in c# with FSUIPC DLL there are also the event.offset or event.timer or event.lvar ? I'm not that familiar with the c# library, but I doubt it very much. I think lvar access is a lot simpler via lua, and you would probably have to implement your own 'event' type mechanism. But check the documentation, or you can ask in the client dll for .net sub-forum: https://forum.simflight.com/forum/167-fsuipc-client-dll-for-net/
hkhoanguyen Posted October 8, 2020 Author Report Posted October 8, 2020 On 10/7/2020 at 1:40 PM, John Dowson said: I'm not that familiar with the c# library, but I doubt it very much. I think lvar access is a lot simpler via lua, and you would probably have to implement your own 'event' type mechanism. But check the documentation, or you can ask in the client dll for .net sub-forum: https://forum.simflight.com/forum/167-fsuipc-client-dll-for-net/ Thanks John, another question, when using ipc.sleep, does it block the whole lua script ? (means other actions wont be able to execute during this sleep ?) Thanks
Pete Dowson Posted October 8, 2020 Report Posted October 8, 2020 43 minutes ago, hkhoanguyen said: when using ipc.sleep, does it block the whole lua script ? (means other actions wont be able to execute during this sleep ?) Yes, that's the point. Lua plug-ins run in their own thread. There can be many running at the same time, but each one is only single-threaded, not multi-threaded. If you need several things going on at once then use more plug-ins. They can communicate using ipc.set and ipc.get. Pete
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