Scratchpad output to the A10C II Profile on 1 Tile

This commit is contained in:
Bailey 2022-07-19 03:20:15 +09:00 committed by GitHub
parent 213e7b4c29
commit d230bccbfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -806,9 +806,19 @@ function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
ExportScript.Tools.SendData(2000, ExportScript.Tools.RoundFreqeuncy((UHF_RADIO:get_frequency()/1000000))) -- ExportScript.Tools.RoundFreqeuncy(frequency (MHz|KHz), format ("7.3"), PrefixZeros (false), LeastValue (0.025))
]]
-- Export ScratchPad
local lScratchPad = ExportScript.Tools.getListIndicatorValue(5)
ExportScript.Tools.SendData(2040, ExportScript.Tools.coerce_nil_to_string(lScratchPad.Scratch_PAD))
-- Export ScratchPad. Recommend 11pt font in DCS-Interface
local lScratchPadGet = ExportScript.Tools.getListIndicatorValue(5)
local lScratchPad = ExportScript.Tools.coerce_nil_to_string(lScratchPadGet.Scratch_PAD) -- .. lScratchPad.Scratch_PAD_Mode
local lScratchPadMode = ExportScript.Tools.coerce_nil_to_string(lScratchPadGet.Scratch_PAD_Mode)
-- https://www.tutorialspoint.com/string-gsub-function-in-lua-programming
lScratchPadMode = string.gsub(lScratchPadMode, "%s+", "") -- removes spaces
local lScratchPadTotal = lScratchPad .. lScratchPadMode -- combines the scratchpad and the mode
if lScratchPadTotal == '' then lScratchPadTotal = '[Sctch]\n[Pad]' end -- abbreviation for scratch due to 7 charPerLine later
ExportScript.Tools.SendData(2040, lScratchPadTotal)
local lScratchPadStacked = splitLines(lScratchPadTotal, 7) -- splits into newlines
lScratchPadStacked = string.gsub(lScratchPadStacked,' ]','_]') -- takes care of the blank space
lScratchPadStacked = string.gsub(lScratchPadStacked,' \n]','_]') -- removes new line with only bracket
ExportScript.Tools.SendData(2041, lScratchPadStacked)
-- AN/ARC-164 UHF and UHF Preset Channel
---------------------------------------------------
@ -1226,6 +1236,27 @@ end
-- Custom functions --
-----------------------------
-- formats the string by putting newlines in the appropriate places
function splitLines(stringIn, charPerLine)
local rows = DIV(#stringIn,charPerLine)
for i = 1, rows, 1 do -- the i's represent the displacement and multipliers needed for the self iterations
stringIn = string.insert(stringIn, '\n', (charPerLine * i) + (i-1))
end
return stringIn
end
-- workaround for floor division. typically //
-- http://lua-users.org/wiki/SimpleRound
function DIV(a,b)
return (a - a % b) / b
end
-- used to insert newlines at the right areas
-- https://stackoverflow.com/questions/59561776/how-do-i-insert-a-string-into-another-string-in-lua
function string.insert(str1, str2, pos)
return str1:sub(1,pos)..str2..str1:sub(pos+1)
end
-----------------------------
-- CDU Export based on Jan Boeckers DCS BIOS
-- https://github.com/dcs-bios/dcs-bios