Modulo:RisF1: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
aggiunta nuova funzione per template:RisF1Team e nuovo parametro |Colonne= da usare quando |Ritiro= è inefficace
Nessun oggetto della modifica
 
(14 versioni intermedie di 2 utenti non mostrate)
Riga 14:
SQ = "000000; color:white; font-size:81%",
NP = "FFFFFF",
NQ = "EFCFCFFFCFCF",
NPQ = "FFCFCF",
SP = "F1F8FF",
Riga 28:
local ris = args[2]
 
if not ris == nil or string.lower(ris) == "inf" then
ris = 0
end
 
local ris2ris = string.gsub(ris,"'","")
 
if tonumber(ris2ris) ~= nil and tonumber(ris2ris) > 3 then
if tonumber(ris2ris) <= zonapunti then
ris2ris = "punti"
else ris2ris = "nopunti"
end
end
 
local colore = tavolozza[ris2ris]
 
if colore == nilcolore or then""
colore = ""
end
 
return "style=\"padding-left:0px;padding-right:0px;background-color:#" .. colore .. "\""
Riga 58 ⟶ 56:
local switch = {["PG"]="'''''",["PP"]="'''",["GV"]="''"}
 
if ris ~= nil then
if switch[apici] ~= nil then
ris = switch[apici] .. ris .. switch[apici]
end
Riga 73 ⟶ 71:
 
local anno = tonumber(frame.args[1])
local annoN = anno or 0
 
anno = (p.ultima() >= annoN) and anno or "default"
if anno == nil then
anno = "default"
end
 
local stagione = tabella[anno]
 
if stagione == nil then
stagione = tabella["default"]
end
 
local seq = stagionetabella["gp"anno].gp
local gareanno = stagionetabella["gare"anno].gare
local str = 'width=3%|' .. p.band({seq[1],anno})
 
Riga 100 ⟶ 91:
 
local argstmp = mw.getCurrentFrame():getParent().args
local anno = tonumber(argstmp["Anno"]) or tonumber(argstmp[1])
local ritiro = tonumber(argstmp["Ritiro"])
local colonne = tonumber(argstmp["Colonne"])
local str = ""
local annoN = anno or 0
 
anno = (p.ultima() >= annoN) and anno or "default"
if anno == nil then
anno = "default"
end
 
local stagione = tabella[anno]
 
if stagione == nil then
stagione = tabella["default"]
end
 
local gareanno = stagionetabella["gare"anno].gare
local max = p.max()
 
if colonne ~= nil and colonne >= gareanno and colonne <= max then
max = colonne
elseif ritiro ~= nil and ritiro >= annoannoN then
max = p.max({ritiro})
end
Riga 138 ⟶ 122:
local str = ""
local anno = tonumber(argstmp["Anno"])
local annoN = anno or 0
 
anno = (p.ultima() >= annoN) and anno or "default"
if anno == nil then
anno = "default"
end
 
local stagionegare = tabella[anno].gare
local zonapunti = tabella[anno].punti
 
if stagione == nil then
stagione = tabella["default"]
end
 
local zonapunti = stagione["punti"]
local lettera = args[1]
local width1 = 'width=3% '
local widthn = '||width=3% '
local gare = stagione["gare"]
local ris = ""
for i=1,gare do
if not lettera == nil or lettera == "" then
paramR = i .. "R"
paramG = "G" .. i
Riga 168 ⟶ 144:
local col = p.colori({zonapunti,argstmp[paramR]})
local note = argstmp[paramN]
if ris == nilris or then""
risnote = note or ""
if i~=1 then
end
str = str .. '||width=3% '
if note == nil then
else str = str .. 'width=3% '
note = ""
end
if i==1 then
str = str .. width1
else str = str .. widthn
end
str = str .. col .. "|&#32;" .. ris .. note
Riga 190 ⟶ 162:
local ritiro = tonumber(args[1])
local max = 7
local ultima = 1950p.ultima()
 
while tabella[ultima] ~= nil do
ultima = ultima + 1
end
ultima = ultima - 1
 
if not ritiro == nil or ritiro > ultima then
ritiro = ultima
end
 
for i = 1951,ritiro do
local stagionegare = tabella[i].gare
localmax = (gare => max) and stagione["gare"] or max
if gare > max then
max = gare
end
end
 
Riga 217 ⟶ 181:
local args = getArgs(frame)
local gp = args[1]
local anno = tostring(args[2])
local dati = tabgp[gp]
local str = ""
 
if dati == nildati or thentabgp["NC"]
dati = tabgp["NC"]
end
 
if not anno == "nil" then
anno = ""
else anno = " " .. anno
Riga 241 ⟶ 203:
local anno = tonumber(argstmp["Anno_di_gara"])
local stagione = tabella[anno]
local gareanno = 0p.max()
if stagione ~= nil then
gareanno = stagione["gare"]
else
gareanno = p.max(stagione)
end
return gareanno
Riga 254 ⟶ 214:
local argstmp = mw.getCurrentFrame():getParent().args
local numero = tonumber(argstmp[1])
local numeroN = numero or 1
 
if numero == nil(numeroN < 10) and numeroN or then10
numero = 1
elseif numero > 10 then
numero = 10
end
 
local lettera = {string.char(65)}
local pilota = argstmp["P1"]
Riga 267 ⟶ 222:
local rowspan = "||rowspan=" .. numero
 
if not punti or punti == nil"" then
punti = " "
end
 
if pilota == nilpilota or " then"
pilota = " "
end
 
if not pos == nil then
pos = "| "
elseif tonumber(pos) == 1 then
pos = ' bgcolor="#FFFFBF"|' .. pos .. "º"
elseif tonumber(pos) ~= nil then
pos = "|" .. pos .. "º"
else pos = "|" .. pos
Riga 289 ⟶ 242:
lettera = {string.char(i+64)}
pilota = argstmp["P" .. i]
if pilota == nilpilota or " then"
pilota = " "
end
output = output .. "|" .. pilota .. "||" .. p.celle(lettera) .. p.vuote() .. "\n|-\n"
end
Riga 297 ⟶ 248:
return output
 
end
 
--La funzione aggiunge la legenda in fondo alle tabelle dei risultati.
function p.legenda(frame)
local args = getArgs(frame, {wrappers = {'Template:RisF1','Template:RisF1Team','Template:VetturaF1'}})
local dim = args["dim"] or 85
local anno = tonumber(args["Anno"]) or 0
local apice = ""
if anno == 2021 then
apice = "<br/>'''Apice''' – Risultato Qualifica Sprint (A punti)"
elseif anno > 2021 then
apice = "<br/>'''Apice''' – Risultato Sprint (A punti)"
end
if args["LEG"] == "1" then
return "{| class=\"wikitable\" style=\"text-align:center; width: 100%; font-size:" .. dim .. "%; margin-top: 0em; margin-bottom: 0em; padding:0\"\n|-\n|rowspan=2 width=5%|'''Legenda'''||style=\"background-color:#ffffbf;width:15%\"|1º posto||style=\"background-color:#dfdfdf;width:15%\"|2º posto||style=\"background-color:#ffdf9f;width:15%\"|3º posto||style=\"background-color:#dfffdf;width:15%\"|A punti||style=\"background-color:#cfcfff;width:15%\"|Senza punti/Non class.||rowspan=2 style=\"background-color:#ffffff;width:20%\"|'''Grassetto''' – Pole position<br/>''Corsivo'' – Giro più veloce" .. apice .. "\n|-\n|style=\"background-color:#000000; color:white\"|Squalificato||style=\"background-color:#efcfff\"|Ritirato||style=\"background-color:#FFFFFF\"|Non partito||style=\"background-color:#FFCFCF\"|Non qualificato||style=\"background-color:#f0ffff\"|Solo prove/Terzo pilota\n|}"
end
 
end
 
function p.vettura(frame)
local argstmp = mw.getCurrentFrame():getParent().args
local numero = tonumber(argstmp["NumeroPiloti"])
local numeroN = numero or 1
numero = (numeroN < 10) and numeroN or 10
 
local pilota = argstmp["P1"]
local punti = argstmp["Punti"]
local pos = argstmp["Pos"]
local rowspan = "||rowspan=" .. numero
 
if not punti or punti == "" then
punti = " "
end
 
pilota = pilota or " "
 
if not pos then
pos = "| "
elseif tonumber(pos) == 1 then
pos = ' bgcolor="#FFFFBF"|' .. pos .. "º"
elseif tonumber(pos) then
pos = "|" .. pos .. "º"
else pos = "|" .. pos
end
 
if argstmp["Ritiro"] or argstmp["Colonne"] then
output = frame:preprocess(pilota) .. p.vuote() .. rowspan .. "|" .. punti .. rowspan .. pos .. "\n|-\n"
else output = frame:preprocess(pilota) .. rowspan .. "|" .. punti .. rowspan .. pos .. "\n|-\n"
end
 
for i=2,numero do
pilota = argstmp["P" .. i]
pilota = pilota or " "
if argstmp["Ritiro"] or argstmp["Colonne"] then
output = output .. "|" .. frame:preprocess(pilota) .. p.vuote() .. "\n|-\n"
else output = output .. "|" .. frame:preprocess(pilota) .. "\n|-\n"
end
end
 
return output
 
end
 
--La funzione determina la stagione più recente di cui sono presenti dati in Modulo:RisF1/Stagioni.
function p.ultima(frame)
local ultima = 1950
while tabella[ultima] do
ultima = ultima + 1
end
ultima = ultima - 1
return ultima
end