Jump to content
The simFlight Network Forums

Goflight MCP Displays (Lua file)


Recommended Posts

  • Replies 79
  • Created
  • Last Reply

Top Posters In This Topic

well back to the airbu as i wanted to update so it also have mach and that works but now it is the heading there shows 1 under. so would this work to on the heading HDG = math.floor(ipc.readLvar("AB_AP_HDG_Select") * 100) / 100

or is there another code for that. as i tryeid the code but it keeps showing hdg 1 degree under on the GOflight MCP. ?

Link to comment
Share on other sites

well back to the airbu as i wanted to update so it also have mach and that works but now it is the heading there shows 1 under. so would this work to on the heading HDG = math.floor(ipc.readLvar("AB_AP_HDG_Select") * 100) / 100

No, that is rounding down the .01 part,. Two things wrong there for a heading 1 under. First is that you don't need headings to 1/100th of a degree, second is that rounding down always reduces, never increases. That's why it is called rounding down. ;-)

All you need to do is round up. To do that keep your current code but add 0.5 before display.

It's really only simple arithmetic, not programming. ;-)

Pete

Link to comment
Share on other sites

yes pete ofcause i think i Z z Z z Z

It worked hdg = math.floor(0.5 + ipc.readLvar("AB_AP_HDG_Select_hist"))

and yes when you say so i can se it is logic as take the variable and add 0.5 that would give if hdg 339,40+0.5 = 339,90 = 340. but also becaus you know what is posible to do in the lines. :smile:

Link to comment
Share on other sites

and yes when you say so i can se it is logic as take the variable and add 0.5 that would give if hdg 339,40+0.5 = 339,90 = 340.

No, 339.4 gives 339 because the "math.floor" of 339.9 is 339. Only 339.5 and above will round up to 340. That's the point -- round up for .5 and above, down otherwise.

That is "normal" rounding, or "rounding to nearest".

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.