Jump to content
The simFlight Network Forums

Multiple event.offset calls not equal


Mr.Rick

Recommended Posts

Hi,  

I have the following in my script:

event.offset(0x0842,"SW","climbp")  -- vertical speed change - 30801
event.offset(0x0842,"SW","climbt")   -- vertical speed change - 7727
event.offset(0x0842,"SW","climbj")   -- vertical speed change - 5505
event.offset(0x0842,"SW","cruisep")  -- vertical speed change - 4260
event.offset(0x0842,"SW","cruiset")  -- vertical speed change - 3499
event.offset(0x0842,"SW","cruisej")  -- vertical speed change - 2972
event.offset(0x0574,"SD","descentp") -- altitude change - 1976
event.offset(0x0574,"SD","descentt") -- altitude change - 641
event.offset(0x0574,"SD","descentj") -- altitude change - 567
event.offset(0x0574,"SD","finalp") -- altitude change - 515
event.offset(0x0574,"SD","finalt")  -- altitude change - 487
event.offset(0x0574,"SD","finalj") -- altitude change - 454

 

You can see they are 2 sets of Offsets, Each set has the same Offset that is called 6 times when it gets triggers.

At ther end of each line is the number of times each event was called during a flight of just over 3 hours.

Is it normal for there to be such a huge difference between the times each event is called? I guess I was expecting them to be called equally.

The issue I am having is when the plane is descending at 4000fpm there are 12 events getting called in rapid succession.  One of the functions (descentj) has a flag that is set when the altitude gets below 27,000 feet.   What I found was that was not set until the plane was at around 6,000 feet and it seems it's because that function is not called often enough to be triggered any earlier.

I am thinking I will have to change the script to have 2 events  and 2 functions and move the other functions into one of those 2.

Cheers - Rick

 

Link to comment
Share on other sites

There is only one changed flag per offset, and when the first event.offset function is called the flag is reset. So the second, and subsequent, event.offset calls will only be made if the flag is changed again. This is why you see a descending number of calls for each event.offset on the same offset. You should only use one event.offset call for each offset.

8 hours ago, Mr.Rick said:

I am thinking I will have to change the script to have 2 events  and 2 functions and move the other functions into one of those 2.

Yes, that is one way to change this. Or just have one event.offset call and function (for each offset), and call the other functions from the one event.offset handling function.

John

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.