Skip to content

Commit

Permalink
Merge pull request #29 from ANDR0ID-DCS/main
Browse files Browse the repository at this point in the history
Updates, Bug Fix, and New Profiles (A29, Hercules, T45)
  • Loading branch information
llamaXc authored Jun 6, 2023
2 parents 727a139 + d7a5f34 commit 35f3931
Show file tree
Hide file tree
Showing 9 changed files with 1,174 additions and 582 deletions.
20 changes: 18 additions & 2 deletions wwt/ufcPatch/aircraft/ufcPatchA10C2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,32 @@ local ufcUtils = require("ufcPatch\\utilities\\ufcPatchUtils")
ufcPatchA10C2 = {}


-- Shows static data for the A10 UFC
-- A10 UFC updated for combination of static and dynamic data by ANDR0ID
function ufcPatchA10C2.generateUFCData()

local MainPanel = GetDevice(0)

local MasterCautionLight = MainPanel:get_argument_value(404)

if MasterCautionLight == 1 then
Warn1 = "M"
Warn2 = "C"
elseif MasterCautionLight == 0 then
Warn1 = ""
Warn2 = ""
end

--local A10C_CDU_ScratchPad = ufcUtils.getDCSListIndication(5) --getListIndicatorValue(5)

--Example off setting the 5 option display windows to static values.
return ufcUtils.buildSimAppProUFCPayload({
option1="HACK",
option2="FUNC",
option3="LTR",
option4="MK",
option5="ALT",
scratchPadString1=Warn1,
scratchPadString2=Warn2,
--scratchPadNumbers=A10C_CDU_ScratchPad.CDU_SUBSET_SCRATCHPAD
})
end

Expand Down
138 changes: 138 additions & 0 deletions wwt/ufcPatch/aircraft/ufcPatchA29B.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
local ufcUtils = require("ufcPatch\\utilities\\ufcPatchUtils")

ufcPatchA29B = {}

function ufcPatchA29B.generateUFCData()

local MainPanel = GetDevice(0)

local Comm1_Button = GetDevice(0):get_argument_value(451)
local Comm2_Button = GetDevice(0):get_argument_value(452)
local AG_Button = GetDevice(0):get_argument_value(454)
local Nav_Button = GetDevice(0):get_argument_value(455)
local AA_Button = GetDevice(0):get_argument_value(456)
local MasterArm = GetDevice(0):get_argument_value(781)

--Radar Altitude FC3
local FC3RadarAlt = {
math.floor((LoGetAltitudeAboveGroundLevel())*3.28)-6 --Covert meters to feet & account for airframe offset
}

local FC3RadarAltitudeString = ""
for index, value in ipairs(FC3RadarAlt) do
local FC3RadarAltitudeStringToAppend = value
if value <= 0.9 then
FC3RadarAltitudeStringToAppend = 0
elseif value >= 9999 then
FC3RadarAltitudeStringToAppend = 9999
end
FC3RadarAltitudeString = tostring(value)
if value < 10 then
FC3RadarAltitudeString = "000"..value
elseif value >= 1000 then
FC3RadarAltitudeString = ""..value
elseif (value >= 100 and value <= 999) then
FC3RadarAltitudeString = "0"..value
elseif (value >= 10 and value <= 99) then
FC3RadarAltitudeString = "00"..value
end
end

--Heading (Magnetic)
local Headingdigits = {math.floor(LoGetMagneticYaw()* (180/math.pi))}

local HeadingString = ""
for index, value in ipairs(Headingdigits) do
local HeadingdigitToAppend = value
if value >= 360 then
HeadingdigitToAppend = 0
end
HeadingString = tostring(value)
if value == -7 then
HeadingString = "353M"
elseif value == -6 then
HeadingString = "354M"
elseif value == -5 then
HeadingString = "355M"
elseif value == -4 then
HeadingString = "356M"
elseif value == -3 then
HeadingString = "357M"
elseif value == -2 then
HeadingString = "358M"
elseif value == -1 then
HeadingString = "359M"
elseif value < 10 then
HeadingString = "00"..value.."M"
elseif value >= 100 then
HeadingString = ""..value.."M"
elseif value >= 10 then
HeadingString = "0"..value.."M"
end
end

--Fuel (Total)
local Fueldigits = {math.floor((LoGetEngineInfo().fuel_internal)*1)} --Kg?

local FuelString = ""
for index, value in ipairs(Fueldigits) do
local FueldigitToAppend = value
if value >= 500 then
FueldigitToAppend = 500
end
FuelString = FuelString..FueldigitToAppend
end

--Airspeed
local Airspeeddigits = {math.floor(LoGetIndicatedAirSpeed()*1.943)} --Convert Meters per Second to Knots, only shows airspeed above 50 knots

local AirspeedString = ""
for index, value in ipairs(Airspeeddigits) do
local AirspeeddigitToAppend = value
if value >= 700 then
AirspeeddigitToAppend = 700
end
AirspeedString = AirspeedString..AirspeeddigitToAppend
end

--Master Arm
if MasterArm == 1 then
MasterArmString = "ARMD"
elseif MasterArm == 0 then
MasterArmString = "SAFE"
elseif MasterArm == -1 then
MasterArmString ="SIM"
end

--Countermeassures
local Flaredigits = LoGetSnares().flare
local Chaffdigits = LoGetSnares().chaff

--Mode String
if Nav_Button == 1 then
Pad1 ="N"
Pad2 ="V"
elseif AA_Button == 1 then
Pad1 = "A"
Pad2 = "A"
elseif AG_Button == 1 then
Pad1 = "A"
Pad2 = "G"
end

--Send info to UFC components
return ufcUtils.buildSimAppProUFCPayload({
scratchPadNumbers=" 29 ",
option1=FC3RadarAltitudeString,
option2=HeadingString,
option3=FuelString,
option4=AirspeedString,
option5=MasterArmString,
com1=Flaredigits,
com2=Chaffdigits,
scratchPadString1=Pad1,
scratchPadString2=Pad2
})
end

return ufcPatchA29B --v1.0 by ANDR0ID
18 changes: 16 additions & 2 deletions wwt/ufcPatch/aircraft/ufcPatchAH64.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,21 @@ local MasterCautInfo = MainPanel:get_argument_value(425) --AH-64 Master Arm Caut
HeadingdigitToAppend = 0
end
HeadingString = tostring(value)
if value < 10 then
if value == -7 then --These strings needed as there is a "negative heading bug" with LoGet
HeadingString = "353M"
elseif value == -6 then
HeadingString = "354M"
elseif value == -5 then
HeadingString = "355M"
elseif value == -4 then
HeadingString = "356M"
elseif value == -3 then
HeadingString = "357M"
elseif value == -2 then
HeadingString = "358M"
elseif value == -1 then
HeadingString = "359M"
elseif value < 10 then
HeadingString = "00"..value.."M"
elseif value >= 100 then
HeadingString = ""..value.."M"
Expand Down Expand Up @@ -119,7 +133,7 @@ local MasterCautInfo = MainPanel:get_argument_value(425) --AH-64 Master Arm Caut
option1 = FC3RadarAltitudeString, --Radar Altitude --
option2 = HeadingString, --Magnetic Heading
option3 = FuelString, --Fuel (Internal) in Gallons
option4 = "T" .. string.format('%.0f', LoGetTrueAirSpeed()*1.943), --True Airspeed (Knots) --1.852
option4 = "T" .. string.format('%.0f', LoGetTrueAirSpeed()*1.943), --True Airspeed (Knots)
option5 = StatusDisplay,
--"B" .. string.format('%.0f', math.floor((LoGetAltitudeAboveSeaLevel() * 3.281) / 10) * 10), --Barometric Altimeter
scratchPadNumbers = string.format('%.0f', math.floor(LoGetVerticalVelocity() * 196.85)) .. " ", --Vertical Velocity (FPM)* 0.3048 * 10
Expand Down
151 changes: 151 additions & 0 deletions wwt/ufcPatch/aircraft/ufcPatchHerc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
local ufcUtils = require("ufcPatch\\utilities\\ufcPatchUtils")

ufcPatchHerc = {}

function ufcPatchHerc.generateUFCData()

local MainPanel = GetDevice(0)
local UHFRadio = GetDevice(18)
local UHFFreq = UHFRadio:get_frequency()

--Radar Altitude FC3
local FC3RadarAlt = {
math.floor(((LoGetAltitudeAboveGroundLevel()))*3.28)-14 --Covert meters to feet & account for airframe offset
}

local FC3RadarAltitudeString = ""
for index, value in ipairs(FC3RadarAlt) do
local FC3RadarAltitudeStringToAppend = value
if value <= 0.9 then
FC3RadarAltitudeStringToAppend = 0
elseif value >= 99999 then
FC3RadarAltitudeStringToAppend = 99999
end
FC3RadarAltitudeString = tostring(value)
if value >= 10000 then
FC3RadarAltitudeString = math.floor(value/1000).."K"
elseif value < 10 then
FC3RadarAltitudeString = "000"..value
elseif value >= 1000 then
FC3RadarAltitudeString = ""..value
elseif (value >= 100 and value <= 999) then
FC3RadarAltitudeString = "0"..value
elseif (value >= 10 and value <= 99) then
FC3RadarAltitudeString = "00"..value
end
end

--Heading (Magnetic)
local Headingdigits = {math.floor(LoGetMagneticYaw()* (180/math.pi))}

local HeadingString = ""
for index, value in ipairs(Headingdigits) do
local HeadingdigitToAppend = value
if value >= 360 then
HeadingdigitToAppend = 0
end
HeadingString = tostring(value)
if value == -7 then
HeadingString = "353M"
elseif value == -6 then
HeadingString = "354M"
elseif value == -5 then
HeadingString = "355M"
elseif value == -4 then
HeadingString = "356M"
elseif value == -3 then
HeadingString = "357M"
elseif value == -2 then
HeadingString = "358M"
elseif value == -1 then
HeadingString = "359M"
elseif value < 10 then
HeadingString = "00"..value.."M"
elseif value >= 100 then
HeadingString = ""..value.."M"
elseif value >= 10 then
HeadingString = "0"..value.."M"
end
end

--Fuel (Total)
local Fueldigits = {math.floor((LoGetEngineInfo().fuel_internal)*44002)}

local FuelString = ""
for index, value in ipairs(Fueldigits) do
local FueldigitToAppend = value
if value >= 44002 then
FueldigitToAppend = 44002
end

FuelSting = tostring(value)
if value >= 10000 then
FuelString = math.floor(value/1000).."K"
elseif value < 10000 then
FuelString = value
end
end

--Airspeed
local Airspeeddigits = {math.floor(LoGetIndicatedAirSpeed()*1.943)} --Convert Meters per Second to Knots

local AirspeedString = ""
for index, value in ipairs(Airspeeddigits) do
local AirspeeddigitToAppend = value
if value >= 9999 then
AirspeeddigitToAppend = 9999
end
AirspeedString = AirspeedString..AirspeeddigitToAppend
end

--Countermeassures
local Flaredigits = {math.floor(LoGetSnares().flare)}

local FlareString = ""
for index, value in ipairs(Flaredigits) do
local FlaredigitsToAppend = value
if value >= 99 then
FlaredigitsToAppend = 99
end
FlareString = FlareString..FlaredigitsToAppend
end

local Chaffdigits = {math.floor(LoGetSnares().chaff)}

local ChaffString = ""
for index, value in ipairs(Chaffdigits) do
local ChaffdigitsToAppend = value
if value >= 99 then
ChaffdigitsToAppend = 99
end
ChaffString = ChaffString..ChaffdigitsToAppend
end

--AN/ARC 164 UHF
local UHFdigits = {math.floor(UHFFreq / 1000)}

local UHFString = ""
for index, value in ipairs(UHFdigits) do
local UHFdigitToAppend = value
if value >= 399975 then
UHFdigitToAppend = 399975
end
UHFString = UHFString..UHFdigitToAppend
end

--Send info to UFC components
return ufcUtils.buildSimAppProUFCPayload({
scratchPadNumbers=UHFString, --UHF Radio Freq
option1=FC3RadarAltitudeString, -- Radar Alt
option2=HeadingString, --Magnetic Heading
option3=FuelString, --Total Fuel (Pounds)
option4=AirspeedString, --True Airspeed (Knots)
option5="C130",
com1=FlareString, --Flare Counter
com2=ChaffString, --Chaff Counter
scratchPadString1="U",
scratchPadString2="H"
})
end

return ufcPatchHerc --v1.0 by ANDR0ID
Loading

0 comments on commit 35f3931

Please sign in to comment.