Modulo:Infobox nave: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
f
arrotondamento eccessivo
 
(7 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]]")
Line 175 ⟶ 177:
local base_arg = parameters[1]
local base_type = parameters[2] or ''
local um = parameters[3] or ''
um = (um and ('&nbsp;' .. um)) or ''
if not base_arg then return end
local elements = {}
Line 196 ⟶ 198:
value_type = (value_type and (value_type .. ": ")) or ''
elements[#elements+1] = value_type .. value_txt .. um
n = n + 1
else
break
Line 203 ⟶ 206:
return elements[1]
else
return '<UL><LI>' .. mw.text.listToText(elements, '</LI>\n<LI>', '</LI>\n<LI>') .. '</LI>\n</UL>'
end
end