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

Goflight MCP Displays (Lua file)

Recommended Posts

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. ?

Share this post


Link to post
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

Share this post


Link to post
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:

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • 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.