Jump to content

DCS BIOS for the Gazelle


Ruahatu

Recommended Posts

For more visibility, I open a new post concerning my questions about my library for the Gazelle.

 

My problem is related to the display of the AM radio.

 

mini_503775radio1.png

 

The radio have 6 digits

Here is the argument

 

AM_Radio_freq_cent = 133,

AM_Radio_freq_dix = 134,

AM_Radio_freq_unite = 136,

AM_Radio_freq_dixieme = 138,

AM_Radio_freq_centieme = 139,

 

The frequency increases by 0.025

 

mini_719098radio2.png

 

When i use this code

local function getVhfNavFreq()
local function a(n) return GetDevice(0):get_argument_value(n) end
return string.format("%.0f%.0f%.0f", a(133)*10, a(134)*10, a(136)*10) .. "." .. string.format("%.0f%.0f", a(138)*10, a(139)*10)
end
defineString("VHFNAV_FREQ", getVhfNavFreq, 7, "VHF NAV Radio", "VHF NAV Frequency")

 

I can see in the controle reference the frequency but the 2 last digit are wrong

 

0.000 = 0

0.025 = 3

0.050 = 5

0.075 = 8

 

I understand that i have to use this type of code

 

local vhf_lut1 = {
   ["0.00"] = "0",
["0.25"] = "3",
   ["0.50"] = "5",
   ["0.75"] = "8"
}

local function getVhfAmFreqency()
   local freq1 = string.format("%.0f",GetDevice(0):get_argument_value(133)):sub(3)
   local freq2 = string.format("%.0f", GetDevice(0):get_argument_value(134)):sub(3)
   local freq3 = string.format("%.0f", GetDevice(0):get_argument_value(136)):sub(3)
   local freq4 = string.format("%.0f", GetDevice(0):get_argument_value(138)):sub(3)
   local freq5 = vhf_lut1[string.format("%.2f",GetDevice(0):get_argument_value(139))]
return freq1 .. freq2 .. freq3 "." .. freq3 .. freq4 .. freq5
end

defineString("AM_DISPLAY", getVhfAmFreqency, 7, "VHFAM Panel", "VHFAM Display")

 

But it does not work and once again i dont understand :cry:

 

Thanks for your help

Link to comment
Share on other sites

Always busy investigating

 

If I understand correctly, the %.0f is used to format the number exactly as many digits as needed by the argument??

 

Someone can explain to me wthat it is the function sub(3) ???

 

Thanks

Link to comment
Share on other sites

:cheer3nc: EUREKA I found it

 

local vhf_lut1 = {
   ["0"] = "00",
["25"] = "25",
   ["50"] = "50",
   ["75"] = "75"
}

local function getVhfAmFreqency()
   local freq1 = string.format("%.0f", GetDevice(0):get_argument_value(133)*10)
   local freq2 = string.format("%.0f", GetDevice(0):get_argument_value(134)*10)--:sub(3)
   local freq3 = string.format("%.0f", GetDevice(0):get_argument_value(136)*10)--:sub(3)
   local freq4 = string.format("%.0f", GetDevice(0):get_argument_value(138)*10)--:sub(3)
   local freq5 = vhf_lut1[string.format("%.0f", GetDevice(0):get_argument_value(139)*100)]
return  freq1 .. freq2 .. freq3 .. "." .. freq4 .. freq5
end

defineString("AM_DISPLAY", getVhfAmFreqency, 7, "VHFAM Panel", "VHFAM Display")

 

But still want info about this :sub(3)

Link to comment
Share on other sites

Ian;3117379']The Lua 5.1 Reference Manual has documentation on every language construct and standard library function' date=' including string.format and string.sub.

 

some_string_variable:sub(n) simply returns everything from the third character onwards and is used to transform something like "0.25" to "25".

 

Thank you Ian for your explanations and your wonderful program :thumbup:

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...