« Module:Monnaie » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
m espace insécable |
||
| (Une version intermédiaire par le même utilisateur non affichée) | |||
| Ligne 34 : | Ligne 34 : | ||
-- ============================================================ | -- ============================================================ | ||
-- Construit une icône + valeur via | -- Construit une icône + valeur via wikilink parsé | ||
-- ============================================================ | -- ============================================================ | ||
local function buildIcon(amount, imageFile, altText | local function buildIcon(amount, imageFile, altText) | ||
local | local img = "[[Fichier:" .. imageFile .. "|24px|link=|alt=" .. altText .. "]]" | ||
return '<span class="monnaie__groupe">' | return '<span class="monnaie__groupe">' | ||
.. '<span class="monnaie__valeur">' .. amount .. '</span>' | .. '<span class="monnaie__valeur">' .. amount .. ' </span>' | ||
.. '<span class="monnaie__icone">' .. img .. '</span>' | .. '<span class="monnaie__icone">' .. img .. '</span>' | ||
.. '</span>' | .. '</span>' | ||
| Ligne 50 : | Ligne 49 : | ||
-- ============================================================ | -- ============================================================ | ||
local function parseString(input) | local function parseString(input) | ||
local n = tonumber(input) | local n = tonumber(input) | ||
if n then return math.floor(n) end | if n then return math.floor(n) end | ||
| Ligne 121 : | Ligne 119 : | ||
-- Construction du HTML | -- Construction du HTML | ||
local parts = {} | local parts = {} | ||
if ecus > 0 then parts[#parts+1] = buildIcon(ecus, IMAGES.ecu, "écu" | if ecus > 0 then parts[#parts+1] = buildIcon(ecus, IMAGES.ecu, "écu") end | ||
if oboles > 0 then parts[#parts+1] = buildIcon(oboles, IMAGES.obole, "obole" | if oboles > 0 then parts[#parts+1] = buildIcon(oboles, IMAGES.obole, "obole") end | ||
if sols > 0 then parts[#parts+1] = buildIcon(sols, IMAGES.sol, "sol" | if sols > 0 then parts[#parts+1] = buildIcon(sols, IMAGES.sol, "sol") end | ||
if #parts == 0 then | if #parts == 0 then | ||
parts[#parts+1] = buildIcon(0, IMAGES.sol, "sol" | parts[#parts+1] = buildIcon(0, IMAGES.sol, "sol") | ||
end | end | ||
local html = '<span class="monnaie" title="' .. tooltip .. '">' | |||
.. table.concat(parts) | .. table.concat(parts) | ||
.. '</span>' | .. '</span>' | ||
return frame:preprocess(html) | |||
end | end | ||
return p | return p | ||