Jump to content
The simFlight Network Forums
hkhoanguyen

GSX Select Option by number does not work with event.key

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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?

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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!

 

 

Share this post


Link to post
Share on other sites

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?

 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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/

 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

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