From 7aa0050960745ffccfaec03fd3d80c8ea9288194 Mon Sep 17 00:00:00 2001 From: Bailey Date: Thu, 29 Jul 2021 14:19:48 +0900 Subject: [PATCH] Update Mi-24P.lua Flare and chaff count is less likely to break on DCS updates --- ExportsModules/Mi-24P.lua | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ExportsModules/Mi-24P.lua b/ExportsModules/Mi-24P.lua index c453366..71672f9 100644 --- a/ExportsModules/Mi-24P.lua +++ b/ExportsModules/Mi-24P.lua @@ -1095,8 +1095,27 @@ function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice) local hindKneeboardInfo = ExportScript.Tools.split(list_indication(8), "%c")--this contains the formated table of the kneeboard - local txt_FLARES_Count = hindKneeboardInfo[18] - local txt_CHAFFS_Count = hindKneeboardInfo[24] + -- Old way of getting the values. Was hardcoded and could break of DCS updates + --local txt_FLARES_Count = hindKneeboardInfo[15] -- original 18 + --local txt_CHAFFS_Count = hindKneeboardInfo[21] -- original 24 + + -- New way of detecting the counts, borrowed from Wizard and the F16 + local txt_FLARES_Count + + for k,v in pairs(hindKneeboardInfo) do + if v == "txt_FLARES_Count" then + txt_FLARES_Count = hindKneeboardInfo[k+1] + end + end + + + local txt_CHAFFS_Count + + for k,v in pairs(hindKneeboardInfo) do + if v == "txt_CHAFFS_Count" then + txt_CHAFFS_Count = hindKneeboardInfo[k+1] + end + end ExportScript.Tools.SendData(3022, string.format(txt_FLARES_Count)) ExportScript.Tools.SendData(3023, string.format(txt_CHAFFS_Count)) @@ -1104,6 +1123,9 @@ function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice) ExportScript.Tools.SendData(3025, string.format("CHAFF\n" .. txt_CHAFFS_Count)) + + + ------------------- -----Hind mike----- -------------------