Skip to content

Commit

Permalink
Merge pull request #3 from llamaXc/fix-huey-altimeter-digit-readout
Browse files Browse the repository at this point in the history
Fix: Huey altimeter rounding error
  • Loading branch information
llamaXc authored Feb 13, 2023
2 parents 2d8ccce + 4862f34 commit 3e06ead
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wwt/ufcPatch/aircraft/ufcPatchHuey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ function ufcPatchHuey.generateUFCData()
local MainPanel = GetDevice(0)

-- Got these argument values from: <DCS_INSTALL>\Mods\aircraft\Uh-1H\Cockpit\Scripts\mainpanel_init.lua
-- DCS get_argument_value returns floats for these values. Example: 7 = .069999999999901. We need to round to get the proper digit
-- By adding .05 and flooring we get the proper digit shown on the altimeter.
local digits = {
math.floor(MainPanel:get_argument_value(468) * 10),
math.floor(MainPanel:get_argument_value(469) * 10),
math.floor(MainPanel:get_argument_value(470) * 10),
math.floor(MainPanel:get_argument_value(471) * 10)
math.floor((MainPanel:get_argument_value(468) + 0.05) * 10),
math.floor((MainPanel:get_argument_value(469)+ 0.05) * 10),
math.floor((MainPanel:get_argument_value(470)+ 0.05) * 10),
math.floor((MainPanel:get_argument_value(471)+ 0.05) * 10)
}

-- Parse digits and build the radar alt string
Expand Down

0 comments on commit 3e06ead

Please sign in to comment.