Module:F1 2021 Results
Yi palo
This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
This will be a replacement for the very complex F1R2021 template. This is currently a work in progress.
Usage
[mali mi di yibu sheena n-niŋ]{{#invoke:F1 2021 Results|function_name}}
Sample
[mali mi di yibu sheena n-niŋ]Pos. | Driver | BHR Tɛmplet:Country data BHR |
EMI |
POR |
ESP |
MON Tɛmplet:Country data MON |
AZE |
Points |
---|---|---|---|---|---|---|---|---|
1 | Fernando Alonso | Ret | 10 | 8 | 17 | 13 | 5 |
local p = {};
local data = {
["VER"] = {
["_points"] = 105,
["BHR"] = "2",
["EMI"] = "1",
["POR"] = "2",
["ESP"] = "2",
["MON"] = "1",
["AZE"] = "",
},
["NOR"] = {
["_points"] = 56,
["BHR"] = "4",
["EMI"] = "3",
["POR"] = "5",
["ESP"] = "8",
["MON"] = "3",
["AZE"] = "",
},
["ALO"] = {
["_points"] = 5,
["BHR"] = "Ret",
["EMI"] = "10",
["POR"] = "8",
["ESP"] = "17",
["MON"] = "13",
["AZE"] = "",
},
}
local colorCodes = {
["1"] = "#FFFFBF",
["2"] = "#DFDFDF",
["3"] = "#FFDF9F",
["Ret"] = "#EFCFFF",
["NC"] = "#CFCFFF",
["DNQ"] = "#FFCFCF",
["DNPQ"] = "#FFCFCF",
["DSQ"] = "#000000; color:white",
["DNS"] = "#FFFFFF",
["C"] = "#FFFFFF",
}
local function getColor(result)
local colorFromTable = colorCodes[result]
if colorFromTable ~= nil then
return colorFromTable
end
local resultAsNumber = tonumber(result)
if resultAsNumber ~= nil then
if 4 <= resultAsNumber and resultAsNumber <= 10 then
return "#DFFFDF"
elseif 11 <= resultAsNumber then
return "#CFCFFF"
end
end
return "none"
end
function p.getRaceResult(frame)
local driverCode = frame.args[1]
local raceCode = frame.args[2]
local result = data[driverCode][raceCode]
local color = getColor(result)
return 'style="background:' .. color .. ';"|' .. result
end
function p.getPoints(frame)
local driverCode = frame.args[1]
return data[driverCode]["_points"]
end
function p.test()
-- For debug only
mw.log(p.getRaceResult({args={"VER", "BHR"}}))
mw.log(p.getPoints({args={"VER"}}))
end
return p