Modulo:Infobox nave: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
f
arrotondamento eccessivo
 
(4 versioni intermedie di 2 utenti non mostrate)
Riga 27:
 
---============================================================
-- arrotonda in base all'ordine di grandezza: 11111->11110, 1111->1111, 111->111,1
-- Autorounding based on the magnitude of value
---============================================================
local function round_auto(num)
local base = - math.floor(math.log10(math.abs(num))) + 13
if base < -3 then base = -3 end
return round(num, base)
Riga 52:
-- Convert string to number ("," are considered as ".")
---============================================================
local function get_value(stxt)
local s = txt
if s then
s = s:gsub("%.(%d%d%d)", "%1" )
local try_convert = s:gsub(",", ".")
return tonumber(try_convert)
Line 111 ⟶ 113:
function p.speed(frame)
local args = getArgs(frame, {frameOnly = true})
local spd_kn = args[1]
local spd_kmh = args[2]
local spd_type = args[3]
if spd_kmh == nil and spd_kn == nil then return '' end
Line 143 ⟶ 145:
if range_type then dump(out, range_type, ":") end
if nmi_formatted then
dump(out, nmi_formatted, "&nbsp; [[Miglio nautico|miglia]]" )
if kn_formatted then
dump(out, " a ", kn_formatted, "&nbsp;[[nodo (unità di misura)|nodi]]")