From 31f5157e17b91a242101c1d3be65ce1da92cbfc0 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Fri, 29 Sep 2023 17:24:56 +0300 Subject: [PATCH 1/8] FC3 migration to Module --- .../DCS-BIOS/lib/meta_files/DCS_API_defs.lua | 6 + Scripts/DCS-BIOS/lib/modules/Module.lua | 23 + .../lib/modules/aircraft_modules/FC3.lua | 494 ++++++++++++++++++ 3 files changed, 523 insertions(+) create mode 100644 Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua diff --git a/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua b/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua index 8cc1b3b92..6ed25c124 100644 --- a/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua +++ b/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua @@ -196,6 +196,10 @@ EngineSide = {} --- @field HydraulicPressure EngineSide --- @diagnostic disable-next-line: duplicate-doc-field --- @field FuelConsumption EngineSide +--- @diagnostic disable-next-line: duplicate-doc-field +--- @field fuel_internal number +---@diagnostic disable-next-line: duplicate-doc-field +--- @field fuel_external number EngineInformation = {} --- @func Returns engine information @@ -207,6 +211,8 @@ function LoGetEngineInfo() end --- @field right number --- @diagnostic disable-next-line: duplicate-doc-field --- @field left number +--- @diagnostic disable-next-line: duplicate-doc-field +--- @field value number Gear status GearValue = {} --- @class MechanicalInformation diff --git a/Scripts/DCS-BIOS/lib/modules/Module.lua b/Scripts/DCS-BIOS/lib/modules/Module.lua index 6659e6510..edfcd6262 100644 --- a/Scripts/DCS-BIOS/lib/modules/Module.lua +++ b/Scripts/DCS-BIOS/lib/modules/Module.lua @@ -98,6 +98,29 @@ function Module:defineFloat(identifier, arg_number, limits, category, descriptio return control end +function Module:define8BitFloatFromGetter(identifier, func, limits, category, description) + -- same as defineFloat, but only allocates an 8-bit int + local max_value = 255 + local intervalLength = limits[2] - limits[1] + local alloc = self:allocateInt(max_value) + + self:addExportHook(function() + alloc:setValue(((func() - limits[1]) / intervalLength) * 255) + end) + + local alloc = moduleBeingDefined.memoryMap:allocateInt({ maxValue = 255 }) + moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks + 1] = function(dev0) + alloc:setValue(((func() - limits[1]) / intervalLength) * 255) + end + + local control = Control:new(category, ControlType.metadata, identifier, description, {}, { + IntegerOutput:new(alloc, Suffix.none, description), + }) + self:addControl(control) + + return control +end + --- Adds a new indicator light control which will enable the LED when the argument value is greater than or equal to 0.3 --- @param identifier string the unique identifier for the control --- @param arg_number integer the dcs argument number diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua new file mode 100644 index 000000000..e33452de4 --- /dev/null +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -0,0 +1,494 @@ +module("FC3", package.seeall) + +local Module = require("Module") + +--- @class FC3: Module +local FC3 = Module:new("FC3", 0x6000, BIOS.FLAMING_CLIFFS_AIRCRAFT) + +local altitude = " -- " +local altitude_ground_level = " ---- " +local _altitude_sea_level = " ---- " +local vertical_velocity = " -- " +local indicated_airspeed = " -- " +local true_air_speed = " -- " +local mach_number = " -- " +local angle_of_attack = " -- " +local radar_altitude = 0 +local fuel_bar = 0 +local fuel_percentage = " -- " +local gload = 0 +local gload_bar = 0 +local vvi_bar = 8 + +local adi_bank = 0.0 +local adi_pitch = 0.0 +local adi_yaw = 0.0 + +local glide_deviation +local side_deviation +local slip_ball_position + +local chaffs +local flares + +local left_rpm = "----" +local right_rpm = "----" +local left_temp = "----" +local right_temp = "----" +local left_hydraulic = "---" +local right_hydraulic = "---" +local left_fuel_consumption = "----" +local right_fuel_consumption = "----" + +local function GetPlaneName() + local selfdata = LoGetSelfData() + if selfdata == nil then + return "XXX" + end + return selfdata.Name +end + +local function LoGetFuelAll() + local engine = LoGetEngineInfo() + if engine == nil then + return + end + return engine.fuel_internal + engine.fuel_external +end + +local function BarFuel(fuel, plane) + local maxFuel = 1000 + + if plane == "A-10A" then + maxFuel = 5029 + elseif plane == "F-15C" then + maxFuel = 6103 + elseif plane == "MiG-29A" or plane == "MiG-29G" then + maxFuel = 3380 + elseif plane == "MiG-29S" then + maxFuel = 3500 + elseif plane == "Su-25" then + maxFuel = 2835 + elseif plane == "Su-25T" then + maxFuel = 3790 + elseif plane == "Su-27" or plane == "Su-33" or plane == "J-11A" then + maxFuel = 9400 + end + + local barf = math.ceil((fuel / maxFuel) * 16) + if barf > 16 then + barf = 16 + end + if barf == nil then + return + end + return barf +end + +local function BarGLoad(gload) + local barg = math.floor((gload / 11) * 16) + + if barg < 0 then + barg = 0 + elseif barg > 16 then + barg = 16 + end + if barg == nil then + return + end + return barg +end + +local function BarVVI(vvi, plane) + local divide = 150 + + if plane == "A-10A" or plane == "F-15C" then + divide = 30 + end + local bar = (vvi / divide) * 8 + if bar < -8 then + bar = -8 + elseif bar < 0 then + bar = math.floor(bar) + elseif bar > 8 then + bar = 8 + elseif bar > 0 then + bar = math.ceil(bar) + end + if bar == nil then + return + end + return bar + 8 +end + +local function allowMach(plane) + if plane == "A-10A" then + return false + elseif plane == "Su-25T" then + return false + else + return true + end +end + +local function allowTAS(plane) + if plane == "Su-25" then + return true + elseif plane == "Su-25T" then + return true + else + return false + end +end + +FC3:addExportHook(function() + local selfdata = LoGetSelfData() + local plane = GetPlaneName() + + local alt_sea = LoGetAltitudeAboveSeaLevel() or 0 + local alt_ground = LoGetAltitudeAboveGroundLevel() or 0 + local alt = alt_sea or 0 + local vvi = LoGetVerticalVelocity() or 0 + local ias = LoGetIndicatedAirSpeed() or 0 + local tas = LoGetTrueAirSpeed() or 0 + local mach = LoGetMachNumber() or 0 + local fuel_all = LoGetFuelAll() or 0 + local aoa = LoGetAngleOfAttack() or 0 + glide_deviation = LoGetGlideDeviation() + side_deviation = LoGetSideDeviation() + slip_ball_position = LoGetSlipBallPosition() + + gload = LoGetAccelerationUnits().y or 0 + fuel_bar = BarFuel(fuel_all, plane) or 0 + gload_bar = BarGLoad(gload) or 0 + vvi_bar = BarVVI(vvi, plane) or 0 + + local engineInfo = LoGetEngineInfo() + if engineInfo ~= nil then + left_rpm = string.format("%3.0d", engineInfo.RPM.left) + right_rpm = string.format("%3.0d", engineInfo.RPM.right) + left_temp = string.format("%4.0d", engineInfo.Temperature.left) + right_temp = string.format("%4.0d", engineInfo.Temperature.right) + left_hydraulic = string.format(engineInfo.HydraulicPressure.left) + right_hydraulic = string.format(engineInfo.HydraulicPressure.right) + left_fuel_consumption = string.format("%4.0d", (engineInfo.FuelConsumption.left * 7936.641)) + right_fuel_consumption = string.format("%4.0d", (engineInfo.FuelConsumption.right * 7936.641)) + end + + local mech = LoGetMechInfo() + if mech ~= nil then + _GearStatus = mech.gear.value + else + _GearStatus = 0 + end + + local chfl = LoGetSnares() + if chfl ~= nil and type(chfl) == "table" then + chaffs = string.format("%3.0d", chfl.chaff) + flares = string.format("%3.0d", chfl.flare) + else + chaffs = "---" + flares = "---" + end + + --[[ US PLANES ]] + -- + if plane == "A-10A" or plane == "F-15C" or plane == "MiG-29G" then + ias = ias * 1.94384449 -- knots + tas = tas * 1.94384449 -- knots + alt = alt * 3.2808399 -- feets + alt_sea = alt_sea * 3.2808399 -- feets + alt_ground = alt_ground * 3.2808399 -- feets + vvi = vvi * 196.850394 -- feets per minute + fuel_all = math.floor(fuel_all * 0.022) * 100 + aoa = aoa + 10 + + if vvi > 6000 then + vvi = 6000 + elseif vvi < -6000 then + vvi = -6000 + end + vvi = vvi / 1000 + + --[[ RADAR ALTIMITER ]] + -- + if plane == "A-10A" or plane == "MiG-29G" then + radar_altitude = 1 + if alt_ground > 5000 then + radar_altitude = 0 + end + end + fuel_all = fuel_all / 100 + fuel_percentage = string.format("%3.1f", math.floor(fuel_all)) + + --[[ RU PLANES ]] + -- + elseif plane == "MiG-29A" or plane == "MiG-29S" or plane == "Su-25" or plane == "Su-25T" or plane == "Su-27" or plane == "Su-33" or plane == "J-11A" then + ias = math.floor(ias * 0.36) * 10 + tas = math.floor(tas * 0.36) * 10 + if tas < 400 then + tas = 400 + end + alt = math.floor(alt * 0.1) * 10 + if alt_ground > 1500 then + radar_altitude = 0 + else + radar_altitude = 1 + end + fuel_all = math.floor(fuel_all / 10) * 10 + if radar_altitude == 0 then + alt = math.floor(alt / 10) * 10 + end + end + + if radar_altitude == 1 then + alt = alt_ground + end + + if alt >= 10000 then + alt = math.floor(alt / 100) + altitude = string.format("%3d ", alt) + else + altitude = string.format("%4d", alt) + end + altitude_ground_level = string.format("%6d", alt_ground) + _altitude_sea_level = string.format("%6d", alt_sea) + + -- AOA + if plane == "A-10A" then + if aoa < 0 then + aoa = 0 + elseif aoa > 30 then + aoa = 30 + end + elseif plane == "F-15C" then + if aoa < 0 then + aoa = 0 + elseif aoa > 45 then + aoa = 45 + end + else + if aoa < -10 then + aoa = -10 + elseif aoa > 40 then + aoa = 40 + end + end + if math.abs(aoa) >= 10 then + angle_of_attack = string.format(" %2d ", aoa) + else + angle_of_attack = string.format("%4.1f", aoa) + end + + if fuel_all > 100 then + fuel_percentage = string.format("%4d", fuel_all) + else + fuel_percentage = string.format("%4.1f", fuel_all) + end + if fuel_percentage == nil then + return + end + + -- G LOAD + if plane == "A-10A" then + if gload < -5 then + gload = -5 + elseif gload > 10 then + gload = 10 + end + end + + indicated_airspeed = string.format("%4d", ias) + + -- MACH NUMBER + if allowMach(plane) then + if mach < 0.5 then + mach = 0.5 + end + mach_number = string.format("%4.2f", mach) + end + -- TAS + if allowTAS(plane) then + true_air_speed = string.format("%4d", tas) + end + + if vvi >= 100 then + vertical_velocity = string.format("%4d", vvi) + elseif vvi >= 10 then + vertical_velocity = string.format("%3d ", vvi) + elseif vvi <= -10 then + vertical_velocity = string.format("%3d ", vvi) + else + vertical_velocity = string.format("%4.1f", vvi) + end + + adi_pitch, adi_bank, adi_yaw = LoGetADIPitchBankYaw() +end) + +--Altitude +FC3:defineString("FC3_ALTITUDE", function() + return altitude or "000000" +end, 6, "Altitude", "Altitude") + +FC3:defineString("FC3_ALTITUDE_GROUND", function() + return altitude_ground_level or "000000" +end, 6, "Altitude", "Altitude above Ground") +FC3:defineString("FC3_ALTITUDE_SEA", function() + return _altitude_sea_level or "000000" +end, 6, "Altitude", "Altitude above Sea Level") +FC3:defineString("FC3_ANGLE_OF_ATTACK", function() + return angle_of_attack or "0000" +end, 4, "String", "Angle of Attack") +FC3:defineString("FC3_FUEL_ALL", function() + return fuel_percentage or "00000" +end, 5, "Engine", "Fuel Remaining") +FC3:defineString("FC3_INDICATED_AIRSPEED", function() + return indicated_airspeed or "0000" +end, 4, "Speed", "Indicated Airspeed") +FC3:defineString("FC3_MACH_NUMBER", function() + return mach_number or "0000" +end, 4, "Speed", "Mach Number") +FC3:defineString("FC3_TRUE_AIRSPEED", function() + return true_air_speed or "0000" +end, 4, "Speed", "True Airspeed") +FC3:defineString("FC3_VERTICAL_VELOCITY", function() + return vertical_velocity or "0000" +end, 4, "Speed", "Vertical Velocity") +FC3:defineIntegerFromGetter("FC3_RADAR_ALTITUDE", function() + return radar_altitude +end, 3, "Altitude", "Radar Altitude") + +--Engine +FC3:defineString("FC3_RPM_L", function() + return left_rpm +end, 3, "Engine", "RPM Left Engine") +FC3:defineString("FC3_RPM_R", function() + return right_rpm +end, 3, "Engine", "RPM Right Engine") +FC3:defineString("FC3_TEMP_L", function() + return left_temp +end, 4, "Engine", "Temperature Left Engine") +FC3:defineString("FC3_TEMP_R", function() + return right_temp +end, 4, "Engine", "Temperature Right Engine") +FC3:defineString("FC3_HYDPRESS_L", function() + return left_hydraulic +end, 10, "Engine", "Hydraulic Pressure Left Engine") +FC3:defineString("FC3_HYDPRESS_R", function() + return right_hydraulic +end, 10, "Engine", "Hydraulic Pressure Right Engine") +FC3:defineString("FC3_FUEL_CON_L", function() + return left_fuel_consumption +end, 10, "Engine", "Fuel Consumption Left Engine") +FC3:defineString("FC3_FUEL_CON_R", function() + return right_fuel_consumption +end, 10, "Engine", "Fuel Consumption Right Engine") + +--Mechanical +FC3:defineIntegerFromGetter("FC3_GEAR", function() + return _GearStatus +end, 1, "Mechanical", "Gear Status") + +--Countermeasures +FC3:defineString("FC3_CHAFF", function() + return chaffs +end, 3, "Countermeasures", "Chaff Counter") +FC3:defineString("FC3_FLARE", function() + return flares +end, 3, "Countermeasures", "Flare Counter") + +--Bar +FC3:defineIntegerFromGetter("FC3_FUEL_BAR", function() + return fuel_bar +end, 16, "Bar", "Fuel Bar") +FC3:defineIntegerFromGetter("FC3_G_LOAD_BAR", function() + return gload_bar +end, 16, "Bar", "G Load Bar") +FC3:defineIntegerFromGetter("FC3_VVI_BAR", function() + return vvi_bar +end, 16, "Bar", "Vertical Velocity Bar") + +--Float + +FC3:define8BitFloatFromGetter("FC3_ADI_BANK", function() + return adi_bank or 0 +end, { -1, 1 }, "Float", "ADI Bank") + +FC3:define8BitFloatFromGetter("FC3_ADI_PITCH", function() + return adi_pitch or 0 +end, { -1, 1 }, "Float", "ADI Pitch") + +FC3:define8BitFloatFromGetter("FC3_ADI_YAW", function() + return adi_yaw or 0 +end, { -1, 1 }, "Float", "ADI Yaw") + +FC3:define8BitFloatFromGetter("FC3_GLIDE_DEVIATION", function() + return glide_deviation or 0 +end, { -1, 1 }, "Float", "Glide Deviation") + +FC3:define8BitFloatFromGetter("FC3_SIDE_DEVIATION", function() + return side_deviation or 0 +end, { -1, 1 }, "Float", "Side Deviation") + +FC3:define8BitFloatFromGetter("FC3_SLIP_BALL_POSITION", function() + return slip_ball_position or 0 +end, { -1, 1 }, "Float", "Slip Ball Position") + +--Externals +FC3:defineIntegerFromGetter("EXT_SPEED_BRAKE_RIGHT", function() + return math.floor(LoGetAircraftDrawArgumentValue(182) * 65535) +end, 65535, "External Aircraft Model", "Right Speed Brake") + +FC3:defineIntegerFromGetter("EXT_SPEED_BRAKE_LEFT", function() + return math.floor(LoGetAircraftDrawArgumentValue(184) * 65535) +end, 65535, "External Aircraft Model", "Left Speed Brake") + +FC3:defineIntegerFromGetter("EXT_POSITION_LIGHT_LEFT", function() + if LoGetAircraftDrawArgumentValue(190) > 0 then + return 1 + else + return 0 + end +end, 1, "External Aircraft Model", "Left Position Light (red)") + +FC3:defineIntegerFromGetter("EXT_POSITION_LIGHT_RIGHT", function() + if LoGetAircraftDrawArgumentValue(191) > 0 then + return 1 + else + return 0 + end +end, 1, "External Aircraft Model", "Right Position Light (green)") + +FC3:defineIntegerFromGetter("EXT_STROBE", function() + if LoGetAircraftDrawArgumentValue(192) > 0 then + return 1 + else + return 0 + end +end, 1, "External Aircraft Model", "Strobe Light") + +FC3:defineIntegerFromGetter("EXT_WOW_NOSE", function() + if LoGetAircraftDrawArgumentValue(1) > 0 then + return 1 + else + return 0 + end +end, 1, "External Aircraft Model", "Weight ON Wheels Nose Gear") + +FC3:defineIntegerFromGetter("EXT_WOW_RIGHT", function() + if LoGetAircraftDrawArgumentValue(4) > 0 then + return 1 + else + return 0 + end +end, 1, "External Aircraft Model", "Weight ON Wheels Right Gear") + +FC3:defineIntegerFromGetter("EXT_WOW_LEFT", function() + if LoGetAircraftDrawArgumentValue(6) > 0 then + return 1 + else + return 0 + end +end, 1, "External Aircraft Model", "Weight ON Wheels Left Gear") + +return FC3 From 98baf9a4bd859bcd7d1f395dd2cd5feaffce9bd7 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Fri, 29 Sep 2023 20:58:46 +0300 Subject: [PATCH 2/8] Multiple fixes FC3 added to test suite Test pattern for module name changed to allow _UPDATE_COUNTER Module:define8BitFloatFromGetter documented --- Scripts/DCS-BIOS/BIOS.lua | 4 +- .../DCS-BIOS/lib/meta_files/DCS_API_defs.lua | 2 +- Scripts/DCS-BIOS/lib/modules/Module.lua | 7 +++ .../lib/modules/aircraft_modules/FC3.lua | 63 +++---------------- Scripts/DCS-BIOS/test/AircraftTest.lua | 6 +- 5 files changed, 24 insertions(+), 58 deletions(-) diff --git a/Scripts/DCS-BIOS/BIOS.lua b/Scripts/DCS-BIOS/BIOS.lua index b0469a354..e34638a24 100644 --- a/Scripts/DCS-BIOS/BIOS.lua +++ b/Scripts/DCS-BIOS/BIOS.lua @@ -76,7 +76,9 @@ BIOS.protocol.writeNewModule(F_22A) dofile(lfs.writedir()..[[Scripts/DCS-BIOS/lib/F-5E-3.lua]]) -- ID = 18, ProperName = F-5E Tiger II dofile(lfs.writedir()..[[Scripts/DCS-BIOS/lib/F-86F Sabre.lua]]) -- ID = 19, ProperName = F-86F Sabre dofile(lfs.writedir()..[[Scripts/DCS-BIOS/lib/FA-18C_hornet.lua]]) -- ID = 20, ProperName = F/A-18C Hornet -dofile(lfs.writedir()..[[Scripts/DCS-BIOS/lib/FC3.lua]]) -- ID = 4, ProperName = Flaming Cliffs 3 +--dofile(lfs.writedir()..[[Scripts/DCS-BIOS/lib/FC3.lua]]) -- ID = 4, ProperName = Flaming Cliffs 3 +local FC3 = require "FC3" +BIOS.protocol.writeNewModule(FC3) -- dofile(lfs.writedir()..[[Scripts/DCS-BIOS/lib/FW-190A8.lua]]) -- ID = 21, ProperName = Fw 190 A-8 Anton local FW_190A8 = require "FW-190A8" BIOS.protocol.writeNewModule(FW_190A8) diff --git a/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua b/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua index 6ed25c124..63e4cc1a9 100644 --- a/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua +++ b/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua @@ -198,7 +198,7 @@ EngineSide = {} --- @field FuelConsumption EngineSide --- @diagnostic disable-next-line: duplicate-doc-field --- @field fuel_internal number ----@diagnostic disable-next-line: duplicate-doc-field +--- @diagnostic disable-next-line: duplicate-doc-field --- @field fuel_external number EngineInformation = {} diff --git a/Scripts/DCS-BIOS/lib/modules/Module.lua b/Scripts/DCS-BIOS/lib/modules/Module.lua index edfcd6262..1c493f858 100644 --- a/Scripts/DCS-BIOS/lib/modules/Module.lua +++ b/Scripts/DCS-BIOS/lib/modules/Module.lua @@ -98,6 +98,13 @@ function Module:defineFloat(identifier, arg_number, limits, category, descriptio return control end +--- Adds a new Float but only but only allocates an 8-bit int. Max value is 255 +--- @param identifier string the unique identifier for the control +--- @param limits number[] a length-2 array with the lower and upper bounds of the data as used in dcs +--- @param func function function to call to get values from game engine +--- @param category string the category in which the control should appear +--- @param description string additional information about the control +--- @return Control control the control which was added to the module function Module:define8BitFloatFromGetter(identifier, func, limits, category, description) -- same as defineFloat, but only allocates an 8-bit int local max_value = 255 diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index e33452de4..25950aef3 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -435,60 +435,13 @@ FC3:define8BitFloatFromGetter("FC3_SLIP_BALL_POSITION", function() end, { -1, 1 }, "Float", "Slip Ball Position") --Externals -FC3:defineIntegerFromGetter("EXT_SPEED_BRAKE_RIGHT", function() - return math.floor(LoGetAircraftDrawArgumentValue(182) * 65535) -end, 65535, "External Aircraft Model", "Right Speed Brake") - -FC3:defineIntegerFromGetter("EXT_SPEED_BRAKE_LEFT", function() - return math.floor(LoGetAircraftDrawArgumentValue(184) * 65535) -end, 65535, "External Aircraft Model", "Left Speed Brake") - -FC3:defineIntegerFromGetter("EXT_POSITION_LIGHT_LEFT", function() - if LoGetAircraftDrawArgumentValue(190) > 0 then - return 1 - else - return 0 - end -end, 1, "External Aircraft Model", "Left Position Light (red)") - -FC3:defineIntegerFromGetter("EXT_POSITION_LIGHT_RIGHT", function() - if LoGetAircraftDrawArgumentValue(191) > 0 then - return 1 - else - return 0 - end -end, 1, "External Aircraft Model", "Right Position Light (green)") - -FC3:defineIntegerFromGetter("EXT_STROBE", function() - if LoGetAircraftDrawArgumentValue(192) > 0 then - return 1 - else - return 0 - end -end, 1, "External Aircraft Model", "Strobe Light") - -FC3:defineIntegerFromGetter("EXT_WOW_NOSE", function() - if LoGetAircraftDrawArgumentValue(1) > 0 then - return 1 - else - return 0 - end -end, 1, "External Aircraft Model", "Weight ON Wheels Nose Gear") - -FC3:defineIntegerFromGetter("EXT_WOW_RIGHT", function() - if LoGetAircraftDrawArgumentValue(4) > 0 then - return 1 - else - return 0 - end -end, 1, "External Aircraft Model", "Weight ON Wheels Right Gear") - -FC3:defineIntegerFromGetter("EXT_WOW_LEFT", function() - if LoGetAircraftDrawArgumentValue(6) > 0 then - return 1 - else - return 0 - end -end, 1, "External Aircraft Model", "Weight ON Wheels Left Gear") +FC3:defineBitFromDrawArgument("EXT_SPEED_BRAKE_RIGHT", 182, "External Aircraft Model", "Right Speed Brake") +FC3:defineBitFromDrawArgument("EXT_SPEED_BRAKE_LEFT", 184, "External Aircraft Model", "Left Speed Brake") +FC3:defineBitFromDrawArgument("EXT_POSITION_LIGHT_LEFT", 190, "External Aircraft Model", "Left Position Light (red)") +FC3:defineBitFromDrawArgument("EXT_POSITION_LIGHT_RIGHT", 191, "External Aircraft Model", "Right Position Light (green)") +FC3:defineBitFromDrawArgument("EXT_STROBE", 192, "External Aircraft Model", "Strobe Light") +FC3:defineBitFromDrawArgument("EXT_WOW_NOSE", 1, "External Aircraft Model", "Weight ON Wheels Nose Gear") +FC3:defineBitFromDrawArgument("EXT_WOW_RIGHT", 4, "External Aircraft Model", "Weight ON Wheels Right Gear") +FC3:defineBitFromDrawArgument("EXT_WOW_LEFT", 6, "External Aircraft Model", "Weight ON Wheels Left Gear") return FC3 diff --git a/Scripts/DCS-BIOS/test/AircraftTest.lua b/Scripts/DCS-BIOS/test/AircraftTest.lua index 4c94f6377..cf73d9450 100644 --- a/Scripts/DCS-BIOS/test/AircraftTest.lua +++ b/Scripts/DCS-BIOS/test/AircraftTest.lua @@ -31,6 +31,10 @@ function TestAircraft:testFW190A8() self:validateModule(require("FW-190A8"), "FW-190A8", 0x3800) end +function TestAircraft:testFC3() + self:validateModule(require("FC3"), "FC3", 0x6000) +end + function TestAircraft:testI16() self:validateModule(require("I-16"), "I-16", 0x4000) end @@ -80,7 +84,7 @@ function TestAircraft:validateControlNames(module_name, documentation) -- start with a letter -- end with a letter or number -- contain only letters, numbers, and underscores - local identifier_pattern = "^%u[%u%d_]*[%u%d]$" + local identifier_pattern = "^[%u%d_]*[%u%d]$" lu.assertNotIsNil(identifier:match(identifier_pattern), module_name .. ": " .. "id " .. identifier .. " did not meet id requirements") -- don't have any consecutive underscores lu.assertNotStrContains(identifier, "__", false) From b4d22e7db8dfbc4e676270e80b6c582dd935b4d8 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Fri, 29 Sep 2023 21:13:10 +0300 Subject: [PATCH 3/8] float to bit for two controls --- Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index 25950aef3..62627f3c8 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -435,8 +435,8 @@ FC3:define8BitFloatFromGetter("FC3_SLIP_BALL_POSITION", function() end, { -1, 1 }, "Float", "Slip Ball Position") --Externals -FC3:defineBitFromDrawArgument("EXT_SPEED_BRAKE_RIGHT", 182, "External Aircraft Model", "Right Speed Brake") -FC3:defineBitFromDrawArgument("EXT_SPEED_BRAKE_LEFT", 184, "External Aircraft Model", "Left Speed Brake") +FC3:defineFloatFromDrawArgument("EXT_SPEED_BRAKE_RIGHT", 182, "External Aircraft Model", "Right Speed Brake") +FC3:defineFloatFromDrawArgument("EXT_SPEED_BRAKE_LEFT", 184, "External Aircraft Model", "Left Speed Brake") FC3:defineBitFromDrawArgument("EXT_POSITION_LIGHT_LEFT", 190, "External Aircraft Model", "Left Position Light (red)") FC3:defineBitFromDrawArgument("EXT_POSITION_LIGHT_RIGHT", 191, "External Aircraft Model", "Right Position Light (green)") FC3:defineBitFromDrawArgument("EXT_STROBE", 192, "External Aircraft Model", "Strobe Light") From 61f607c6fa5e01a03a20740163cfce493932ca60 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sat, 30 Sep 2023 11:16:24 +0300 Subject: [PATCH 4/8] FC3 Export hook split up. Removed old code remnant from Module DCS_API* files list_indication documentation corrected --- .../DCS-BIOS/lib/meta_files/DCS_API_defs.lua | 2 +- Scripts/DCS-BIOS/lib/modules/Module.lua | 5 - .../lib/modules/aircraft_modules/FC3.lua | 265 +++++++++++------- .../DCS-BIOS/test/compile/DCS_API_mocks.lua | 6 +- 4 files changed, 172 insertions(+), 106 deletions(-) diff --git a/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua b/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua index 63e4cc1a9..d9f78f60b 100644 --- a/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua +++ b/Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua @@ -133,7 +133,7 @@ CounterMeasures = {} --- @return CounterMeasures function LoGetSnares() end ---- @func Returns a list of strings for a cockpit indicator (screen) +--- @func Returns a string for a cockpit indicator (screen) --- @return string function list_indication(indicator_id) end diff --git a/Scripts/DCS-BIOS/lib/modules/Module.lua b/Scripts/DCS-BIOS/lib/modules/Module.lua index 1c493f858..7c9b0f10c 100644 --- a/Scripts/DCS-BIOS/lib/modules/Module.lua +++ b/Scripts/DCS-BIOS/lib/modules/Module.lua @@ -115,11 +115,6 @@ function Module:define8BitFloatFromGetter(identifier, func, limits, category, de alloc:setValue(((func() - limits[1]) / intervalLength) * 255) end) - local alloc = moduleBeingDefined.memoryMap:allocateInt({ maxValue = 255 }) - moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks + 1] = function(dev0) - alloc:setValue(((func() - limits[1]) / intervalLength) * 255) - end - local control = Control:new(category, ControlType.metadata, identifier, description, {}, { IntegerOutput:new(alloc, Suffix.none, description), }) diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index 62627f3c8..ebe50d0cf 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -8,17 +8,21 @@ local FC3 = Module:new("FC3", 0x6000, BIOS.FLAMING_CLIFFS_AIRCRAFT) local altitude = " -- " local altitude_ground_level = " ---- " local _altitude_sea_level = " ---- " +local radar_altitude = 0 + local vertical_velocity = " -- " local indicated_airspeed = " -- " local true_air_speed = " -- " local mach_number = " -- " +local vvi_bar = 8 + local angle_of_attack = " -- " -local radar_altitude = 0 + local fuel_bar = 0 local fuel_percentage = " -- " + local gload = 0 local gload_bar = 0 -local vvi_bar = 8 local adi_bank = 0.0 local adi_pitch = 0.0 @@ -31,6 +35,7 @@ local slip_ball_position local chaffs local flares +local gear_status local left_rpm = "----" local right_rpm = "----" local left_temp = "----" @@ -142,73 +147,18 @@ local function allowTAS(plane) end FC3:addExportHook(function() - local selfdata = LoGetSelfData() + --[[ Altitude ]] local plane = GetPlaneName() - local alt_sea = LoGetAltitudeAboveSeaLevel() or 0 local alt_ground = LoGetAltitudeAboveGroundLevel() or 0 local alt = alt_sea or 0 - local vvi = LoGetVerticalVelocity() or 0 - local ias = LoGetIndicatedAirSpeed() or 0 - local tas = LoGetTrueAirSpeed() or 0 - local mach = LoGetMachNumber() or 0 - local fuel_all = LoGetFuelAll() or 0 - local aoa = LoGetAngleOfAttack() or 0 - glide_deviation = LoGetGlideDeviation() - side_deviation = LoGetSideDeviation() - slip_ball_position = LoGetSlipBallPosition() - - gload = LoGetAccelerationUnits().y or 0 - fuel_bar = BarFuel(fuel_all, plane) or 0 - gload_bar = BarGLoad(gload) or 0 - vvi_bar = BarVVI(vvi, plane) or 0 - - local engineInfo = LoGetEngineInfo() - if engineInfo ~= nil then - left_rpm = string.format("%3.0d", engineInfo.RPM.left) - right_rpm = string.format("%3.0d", engineInfo.RPM.right) - left_temp = string.format("%4.0d", engineInfo.Temperature.left) - right_temp = string.format("%4.0d", engineInfo.Temperature.right) - left_hydraulic = string.format(engineInfo.HydraulicPressure.left) - right_hydraulic = string.format(engineInfo.HydraulicPressure.right) - left_fuel_consumption = string.format("%4.0d", (engineInfo.FuelConsumption.left * 7936.641)) - right_fuel_consumption = string.format("%4.0d", (engineInfo.FuelConsumption.right * 7936.641)) - end - - local mech = LoGetMechInfo() - if mech ~= nil then - _GearStatus = mech.gear.value - else - _GearStatus = 0 - end - - local chfl = LoGetSnares() - if chfl ~= nil and type(chfl) == "table" then - chaffs = string.format("%3.0d", chfl.chaff) - flares = string.format("%3.0d", chfl.flare) - else - chaffs = "---" - flares = "---" - end --[[ US PLANES ]] -- if plane == "A-10A" or plane == "F-15C" or plane == "MiG-29G" then - ias = ias * 1.94384449 -- knots - tas = tas * 1.94384449 -- knots alt = alt * 3.2808399 -- feets alt_sea = alt_sea * 3.2808399 -- feets alt_ground = alt_ground * 3.2808399 -- feets - vvi = vvi * 196.850394 -- feets per minute - fuel_all = math.floor(fuel_all * 0.022) * 100 - aoa = aoa + 10 - - if vvi > 6000 then - vvi = 6000 - elseif vvi < -6000 then - vvi = -6000 - end - vvi = vvi / 1000 --[[ RADAR ALTIMITER ]] -- @@ -218,24 +168,17 @@ FC3:addExportHook(function() radar_altitude = 0 end end - fuel_all = fuel_all / 100 - fuel_percentage = string.format("%3.1f", math.floor(fuel_all)) --[[ RU PLANES ]] -- elseif plane == "MiG-29A" or plane == "MiG-29S" or plane == "Su-25" or plane == "Su-25T" or plane == "Su-27" or plane == "Su-33" or plane == "J-11A" then - ias = math.floor(ias * 0.36) * 10 - tas = math.floor(tas * 0.36) * 10 - if tas < 400 then - tas = 400 - end alt = math.floor(alt * 0.1) * 10 if alt_ground > 1500 then radar_altitude = 0 else radar_altitude = 1 end - fuel_all = math.floor(fuel_all / 10) * 10 + if radar_altitude == 0 then alt = math.floor(alt / 10) * 10 end @@ -251,10 +194,118 @@ FC3:addExportHook(function() else altitude = string.format("%4d", alt) end + altitude_ground_level = string.format("%6d", alt_ground) _altitude_sea_level = string.format("%6d", alt_sea) +end) + +FC3:addExportHook(function() + --[[ Speed ]] + local plane = GetPlaneName() + local vvi = LoGetVerticalVelocity() or 0 + vvi_bar = BarVVI(vvi, plane) or 0 + local ias = LoGetIndicatedAirSpeed() or 0 + local tas = LoGetTrueAirSpeed() or 0 + local mach = LoGetMachNumber() or 0 + + --[[ US PLANES ]] + -- + if plane == "A-10A" or plane == "F-15C" or plane == "MiG-29G" then + ias = ias * 1.94384449 -- knots + tas = tas * 1.94384449 -- knots + vvi = vvi * 196.850394 -- feets per minute + + if vvi > 6000 then + vvi = 6000 + elseif vvi < -6000 then + vvi = -6000 + end + vvi = vvi / 1000 + + --[[ RU PLANES ]] + -- + elseif plane == "MiG-29A" or plane == "MiG-29S" or plane == "Su-25" or plane == "Su-25T" or plane == "Su-27" or plane == "Su-33" or plane == "J-11A" then + ias = math.floor(ias * 0.36) * 10 + tas = math.floor(tas * 0.36) * 10 + if tas < 400 then + tas = 400 + end + end + + indicated_airspeed = string.format("%4d", ias) + + -- MACH NUMBER + if allowMach(plane) then + if mach < 0.5 then + mach = 0.5 + end + mach_number = string.format("%4.2f", mach) + end + + -- TAS + if allowTAS(plane) then + true_air_speed = string.format("%4d", tas) + end + + if vvi >= 100 then + vertical_velocity = string.format("%4d", vvi) + elseif vvi >= 10 then + vertical_velocity = string.format("%3d ", vvi) + elseif vvi <= -10 then + vertical_velocity = string.format("%3d ", vvi) + else + vertical_velocity = string.format("%4.1f", vvi) + end +end) + +FC3:addExportHook(function() + --[[ Fuel ]] + local plane = GetPlaneName() + local fuel_all = LoGetFuelAll() or 0 + local engineInfo = LoGetEngineInfo() + + if engineInfo ~= nil then + left_fuel_consumption = string.format("%4.0d", (engineInfo.FuelConsumption.left * 7936.641)) + right_fuel_consumption = string.format("%4.0d", (engineInfo.FuelConsumption.right * 7936.641)) + end + + --[[ US PLANES ]] + -- + if plane == "A-10A" or plane == "F-15C" or plane == "MiG-29G" then + fuel_all = math.floor(fuel_all * 0.022) * 100 + fuel_all = fuel_all / 100 + fuel_percentage = string.format("%3.1f", math.floor(fuel_all)) + + --[[ RU PLANES ]] + -- + elseif plane == "MiG-29A" or plane == "MiG-29S" or plane == "Su-25" or plane == "Su-25T" or plane == "Su-27" or plane == "Su-33" or plane == "J-11A" then + fuel_all = math.floor(fuel_all / 10) * 10 + end + + fuel_bar = BarFuel(fuel_all, plane) or 0 + + if fuel_all > 100 then + fuel_percentage = string.format("%4d", fuel_all) + else + fuel_percentage = string.format("%4.1f", fuel_all) + end +end) + +FC3:addExportHook(function() + --[[Angle of attack]] + local plane = GetPlaneName() + local aoa = LoGetAngleOfAttack() or 0 + + --[[ US PLANES ]] + -- + if plane == "A-10A" or plane == "F-15C" or plane == "MiG-29G" then + aoa = aoa + 10 + + --[[ RU PLANES ]] + -- + elseif plane == "MiG-29A" or plane == "MiG-29S" or plane == "Su-25" or plane == "Su-25T" or plane == "Su-27" or plane == "Su-33" or plane == "J-11A" then + end - -- AOA if plane == "A-10A" then if aoa < 0 then aoa = 0 @@ -274,20 +325,61 @@ FC3:addExportHook(function() aoa = 40 end end + if math.abs(aoa) >= 10 then angle_of_attack = string.format(" %2d ", aoa) else angle_of_attack = string.format("%4.1f", aoa) end +end) - if fuel_all > 100 then - fuel_percentage = string.format("%4d", fuel_all) +FC3:addExportHook(function() + --[[Engine & Mechanical]] + local engineInfo = LoGetEngineInfo() + local mech = LoGetMechInfo() + + if engineInfo ~= nil then + left_rpm = string.format("%3.0d", engineInfo.RPM.left) + right_rpm = string.format("%3.0d", engineInfo.RPM.right) + left_temp = string.format("%4.0d", engineInfo.Temperature.left) + right_temp = string.format("%4.0d", engineInfo.Temperature.right) + left_hydraulic = string.format(engineInfo.HydraulicPressure.left) + right_hydraulic = string.format(engineInfo.HydraulicPressure.right) + end + + if mech ~= nil then + gear_status = mech.gear.value else - fuel_percentage = string.format("%4.1f", fuel_all) + gear_status = 0 end - if fuel_percentage == nil then - return +end) + +FC3:addExportHook(function() + --[[Deviation and Slipball]] + + glide_deviation = LoGetGlideDeviation() + side_deviation = LoGetSideDeviation() + slip_ball_position = LoGetSlipBallPosition() +end) + +FC3:addExportHook(function() + --[[Countermeasures]] + local counter_measures = LoGetSnares() + + if counter_measures ~= nil and type(counter_measures) == "table" then + chaffs = string.format("%3.0d", counter_measures.chaff) + flares = string.format("%3.0d", counter_measures.flare) + else + chaffs = "---" + flares = "---" end +end) + +FC3:addExportHook(function() + --[[G Load]] + local plane = GetPlaneName() + gload = LoGetAccelerationUnits().y or 0 + gload_bar = BarGLoad(gload) or 0 -- G LOAD if plane == "A-10A" then @@ -297,31 +389,10 @@ FC3:addExportHook(function() gload = 10 end end +end) - indicated_airspeed = string.format("%4d", ias) - - -- MACH NUMBER - if allowMach(plane) then - if mach < 0.5 then - mach = 0.5 - end - mach_number = string.format("%4.2f", mach) - end - -- TAS - if allowTAS(plane) then - true_air_speed = string.format("%4d", tas) - end - - if vvi >= 100 then - vertical_velocity = string.format("%4d", vvi) - elseif vvi >= 10 then - vertical_velocity = string.format("%3d ", vvi) - elseif vvi <= -10 then - vertical_velocity = string.format("%3d ", vvi) - else - vertical_velocity = string.format("%4.1f", vvi) - end - +FC3:addExportHook(function() + --[[Pitch Bank Yaw]] adi_pitch, adi_bank, adi_yaw = LoGetADIPitchBankYaw() end) @@ -386,7 +457,7 @@ end, 10, "Engine", "Fuel Consumption Right Engine") --Mechanical FC3:defineIntegerFromGetter("FC3_GEAR", function() - return _GearStatus + return gear_status end, 1, "Mechanical", "Gear Status") --Countermeasures diff --git a/Scripts/DCS-BIOS/test/compile/DCS_API_mocks.lua b/Scripts/DCS-BIOS/test/compile/DCS_API_mocks.lua index a26c90219..bbabf3f16 100644 --- a/Scripts/DCS-BIOS/test/compile/DCS_API_mocks.lua +++ b/Scripts/DCS-BIOS/test/compile/DCS_API_mocks.lua @@ -143,10 +143,10 @@ function LoGetSnares() return CounterMeasures end ---- @func Returns a list of strings for a cockpit indicator (screen) ---- @return string[] +--- @func Returns a string for a cockpit indicator (screen) +--- @return string function list_indication(indicator_id) - return { "A", "B", "C" } + return "A" end CockpitPage = "" From df4e6c1b84acf215fd5680e63af0bee1211caa92 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sat, 30 Sep 2023 11:29:02 +0300 Subject: [PATCH 5/8] fuel_bar correction --- Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index ebe50d0cf..631fb7398 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -262,6 +262,7 @@ FC3:addExportHook(function() --[[ Fuel ]] local plane = GetPlaneName() local fuel_all = LoGetFuelAll() or 0 + fuel_bar = BarFuel(fuel_all, plane) or 0 local engineInfo = LoGetEngineInfo() if engineInfo ~= nil then @@ -282,8 +283,6 @@ FC3:addExportHook(function() fuel_all = math.floor(fuel_all / 10) * 10 end - fuel_bar = BarFuel(fuel_all, plane) or 0 - if fuel_all > 100 then fuel_percentage = string.format("%4d", fuel_all) else From f4d2b4b791a270b273578befc24f8075fc6755f6 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sat, 30 Sep 2023 21:30:27 +0300 Subject: [PATCH 6/8] barf can't be nil --- Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index 631fb7398..e20a76be4 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -84,9 +84,6 @@ local function BarFuel(fuel, plane) if barf > 16 then barf = 16 end - if barf == nil then - return - end return barf end @@ -399,7 +396,6 @@ end) FC3:defineString("FC3_ALTITUDE", function() return altitude or "000000" end, 6, "Altitude", "Altitude") - FC3:defineString("FC3_ALTITUDE_GROUND", function() return altitude_ground_level or "000000" end, 6, "Altitude", "Altitude above Ground") From 8170dfa879a2431c6daa69e02c84c124ea5c8275 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sat, 30 Sep 2023 21:33:43 +0300 Subject: [PATCH 7/8] removed nil checks --- Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index e20a76be4..4279e512e 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -95,9 +95,7 @@ local function BarGLoad(gload) elseif barg > 16 then barg = 16 end - if barg == nil then - return - end + return barg end @@ -117,9 +115,7 @@ local function BarVVI(vvi, plane) elseif bar > 0 then bar = math.ceil(bar) end - if bar == nil then - return - end + return bar + 8 end From 0d0e7c622482b3ef3df0d0a68081290b2288826f Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sat, 30 Sep 2023 21:41:20 +0300 Subject: [PATCH 8/8] condensing functions --- .../lib/modules/aircraft_modules/FC3.lua | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua index 4279e512e..f523790ab 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/FC3.lua @@ -120,23 +120,11 @@ local function BarVVI(vvi, plane) end local function allowMach(plane) - if plane == "A-10A" then - return false - elseif plane == "Su-25T" then - return false - else - return true - end + return plane ~= "A-10A" and plane ~= "Su-25T" end local function allowTAS(plane) - if plane == "Su-25" then - return true - elseif plane == "Su-25T" then - return true - else - return false - end + return plane == "Su-25" or plane == "Su-25T" end FC3:addExportHook(function() @@ -339,11 +327,7 @@ FC3:addExportHook(function() right_hydraulic = string.format(engineInfo.HydraulicPressure.right) end - if mech ~= nil then - gear_status = mech.gear.value - else - gear_status = 0 - end + gear_status = mech and mech.gear.value or 0 end) FC3:addExportHook(function()