Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I currently have a Use-Case where I absolutely need to set a L-Var (to allow User Interaction again) when my Lua Script exits.
So my function called by the event Library is an Oneliner with ipc.writeLvar - but it seems the Time is not enough for this one L-Var to be set before it is killed. Even tried via ipc.execCalcCode without success.

Posted

Please try increasing the TimeForLuaClosing ini parameter - see the Advanced User guide for details. However, I would have thought that the default of 2 seconds would be enough to set an lvar value - I will take a look later...

John
 

Posted

By the way, how are you exiting the lua script - are you killing it manually (i.e. LuaKill), or is it being killed automatically as the flight has ended? In case of the latter, it may be that the connection to the FS has been terminated before the request to update the lvar can be sent.
Maybe try adding an ipc.log call after the request to set the lvar -  does this message get logged? 

Posted
3 hours ago, John Dowson said:

Please try increasing the TimeForLuaClosing ini parameter - see the Advanced User guide for details. However, I would have thought that the default of 2 seconds would be enough to set an lvar value - I will take a look later...

Event setting this ini parameter to the maximum of 20 seconds still doesn't allow lvars to be updated in the terminate function, so it looks like such calls are blocked when terminating. I am not sure why or if there is anything that can be done about it at the moment - I will look into this and get back to you.

John

Posted

I can see the problem (windows messages sent from terminating lua processes are not being processed) but am not sure what can be done about this at the moment.

I will look into this further after the SU15 release.

John

Posted
4 hours ago, John Dowson said:

By the way, how are you exiting the lua script - are you killing it manually (i.e. LuaKill), or is it being killed automatically as the flight has ended? In case of the latter, it may be that the connection to the FS has been terminated before the request to update the lvar can be sent.
Maybe try adding an ipc.log call after the request to set the lvar -  does this message get logged? 

For testing I used a button with LuaKill bound.

Yeah tried that - the Log-Message did not appear either

 

37 minutes ago, John Dowson said:

I can see the problem (windows messages sent from terminating lua processes are not being processed) but am not sure what can be done about this at the moment.

I will look into this further after the SU15 release.

Alright, sounds good!
If it helps anything, it would already help for that Use-Case if one Call to ipc.execCalcCode would come through (can set the L-Var via that also)

Posted
3 minutes ago, Fragtality said:

If it helps anything, it would already help for that Use-Case if one Call to ipc.execCalcCode would come through (can set the L-Var via that also)

Lua threads have no access to the FS, and they can only communicate by sending (windows) messages to the main thread that communicates with the FS. The problem is that these messages are not being sent once the lua thread is closing, so this applies to all lua calls that would interact with the FS. The terminate function should be used to close things down on the client side really, i.e. no interaction with the FS.

I am not sure what or if anything can be done about this at the moment, but I will take a look after the SU15 release. You may have to set up something manual to achieve what you want, such has having an event.flag function to set/write the lvar value and then overload the LuaKill assignment to first set the flag (LuaSet) , to trigger the lvar update, and then kill the script (or call the LuaSet on press and the LuaKill on release)..

John

Posted
On 3/21/2024 at 5:05 PM, John Dowson said:

I am not sure what or if anything can be done about this at the moment, but I will take a look after the SU15 release.

Well then don't put any Effort in it - after some further Testing I won't use the L-Var in Question anyways. Basically another "My Way or the Highway" GSX Design Decision I won't pursue further 🤷‍♂️

Posted

I will take a look anyway and either update to allow calls that go to the FS when the thread is terminating, if possible, or I will update the documentation to specify what is allowed in a terminate function.

It is interesting that a dying thread cannot send/post messages to another thread (or so it seems) and I would like to understand why and if this can be changed. I can also maybe look into changing the order of things, and process the terminate event before starting the thread termination, but that may not be possible, for various reasons.

I may also update to post some messages (asynchronous) rather than send (synchronous) as this will allow subsequent calls to be processed, although the messages still won't be delivered/received/processed, for the same reason as already mentioned, but will allow any other calls to be executed

Cheers,

John.

 

Posted

Sure, I mean it is an interesting Problem nonetheless! 😃

Just wanted to inform you that this one Use-Case from one User already died because stubbornness  😅

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.