Jump to content
The simFlight Network Forums
Sign in to follow this  
ark1320

event.offset() questions

Recommended Posts

Hi Pete,

In the documentation for event.offset() it says:

The function is also executed initially, when the plugin is first run, in order to initialise things. This saves using an explicit call to do the same.

Q1.  Does this mean, for example, if the purpose of the called function is to terminate the script with an ipc.exit() command when the value in the offset changes, the script will be immediately terminated because the function is executed automatically when the script is first run even though the offset value has not changed?

Q2. If execution of the script has been suspended with an ipc.sleep() command, will a change in the offset being monitored by event.offset() be missed or ignored? In other words, does ipc.sleep() also suspend the action of the event.offset() command?

Thanks,

Al

 

Share this post


Link to post
Share on other sites
13 minutes ago, ark1320 said:

Q1.  Does this mean, for example, if the purpose of the called function is to terminate the script with an ipc.exit() command when the value in the offset changes, the script will be immediately terminated because the function is executed automatically when the script is first run even though the offset value has not changed?

Yes. You would need to check the value supplied for the offset to see if has changed to the value you'd expect for a termination.

15 minutes ago, ark1320 said:

Q2. If execution of the script has been suspended with an ipc.sleep() command, will a change in the offset being monitored by event.offset() be missed or ignored? In other words, does ipc.sleep() also suspend the action of the event.offset() command?

The sleep actually suspends the Lua's thread by calling the Windows sleep function. that's more efficient than maintaining a watch on the time in a loop.

Events being monitored will still be registered during the sleep, but after the sleep you will only receive the last such event. They aren't queued and fed to you one by one.

Pete

 

 

Share this post


Link to post
Share on other sites
On 6/12/2018 at 9:13 AM, Pete Dowson said:

Yes. You would need to check the value supplied for the offset to see if has changed to the value you'd expect for a termination.

OK, I see. And if the only condition you were trying to detect was a change in the offset value, rather then a particular offset value, you would need to identify the first call to the function associated with event.offset() and handle that as a special case.

Thx,

Al

Share this post


Link to post
Share on other sites
On 6/12/2018 at 4:55 PM, ark1320 said:

In the documentation for event.offset() it says:

The function is also executed initially, when the plugin is first run, in order to initialise things. This saves using an explicit call to do the same.

Pete,

A quick question: Are there other event types, where the function is called initially to initialize things? A quick check in the documentation did not show other types? This would be good to know, to identify and possibly ignore such initial calls when starting up the LUA modules.

Thanks in advance.
Reinhard

 

Share this post


Link to post
Share on other sites
3 hours ago, aua668 said:

Are there other event types, where the function is called initially to initialize things?

No, only the offset ones, so that the plug-in gets the initial value -- otherwise how can it determine what the difference is when a change is notified? And there are some applications for plug-ins where the initial value is essential -- things that don't change often, but are needed for display on a gauge or similar. I actually use a plug-in to drive my Flight Illusion cockpit gauges.

Things like switch and axis positions have initial values, but FSUIPC doesn't detect a position till it changes and it gets notified.

Pete

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

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.