Jump to content
The simFlight Network Forums

event.offsetmask(offset, mask, "type", "function-name")


Recommended Posts

Hi all.

I am trying to create a lua event handler which is triggered whenever a FSUIPC offset reaches a certain value (rather than polling the offset).

The event shall trigger if my aircraft passes 10'000ft.

Reading through the FSUIPC "Lua Library" document I noted the "event.offsetmask" handler... would this do the trick? I have researched the topic of masking but the penny hasn't dropped and I would appreciate some guidance, perhaps a small example to solve the above...   

event.offsetmask (0x3324, ????, UD, "myfunction")

Thanks in advance

Thomas

 

 

 

 

 

Link to comment
Share on other sites

On 9/22/2016 at 3:27 PM, thomas747400 said:

The event shall trigger if my aircraft passes 10'000ft.

Reading through the FSUIPC "Lua Library" document I noted the "event.offsetmask" handler... would this do the trick?

Not really.

Masks are binary patterns of bits, designed to allow you to test for specific bit changes in a bit-oriented value, of which there are plenty (usually indicating conditions or switch settings).

The number 10,000 in decimal is Hex 0x2710, so you can't even get close with a mask of x2000, which would trigger at 8192.

Really it is easiest just to take all numbers and look out for 10000 or the first value you see above. If you really thought that might be detrimental to performance, use a Timer event instead, maybe for 100 mSecs, and read the offset on that to check.

Pete

 

Link to comment
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
×
×
  • 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.