Module:Ability/new/2: Difference between revisions
From Inkipedia, the Splatoon wiki
(Testing two separate frame object calls: from an invoking template and from another module, instead of just the former.) |
m (removed args field if called from another module via Require:Module) |
||
Line 8: | Line 8: | ||
function p.requireFromModule(frame) | function p.requireFromModule(frame) | ||
return p.chipIcon( | return p.chipIcon( | ||
frame | frame.game, | ||
frame | frame.name, | ||
frame | frame.size, | ||
frame | frame.icononly | ||
) | ) | ||
end | end |
Revision as of 08:10, 6 March 2024
Documentation for this module may be created at Module:Ability/new/2/doc
local p = {} local gameShortened = require("Module:GameShortened") local disambigName = { ["Recon"] = true, } function p.requireFromModule(frame) return p.chipIcon( frame.game, frame.name, frame.size, frame.icononly ) end function p.invokeFromTemplate(frame) local args = frame:getParent().args local game = args.game local name = args.name local size = args.size local icononly = args.icononly return p.getAbilityIcon(game, name, size, icononly) end function p.getAbilityIcon(game, name, size, icononly) local result local abilityIcon local linkText = name local displayText = name local abilityFileName = name game = gameShortened.getGame(game) if size == nil then size = 24 end if name == "?" then linkText = "Gear ability" displayText = "None" --Exaskliri wants to display link text by default, even for "?" abilityFileName = "Locked" end if disambigName[name] then linkText = linkText .. " (ability)" end abilityIcon = string.format("[[File:%s_Ability_%s.png|%dpx|link=%s]]", game, abilityFileName, size, linkText) local iconSpan = mw.html.create("span") local padSize = size * 0.05 iconSpan :css("display", "inline-block") :css("vertical-align", "middle") :css("width", size.."px") :css("height", size.."px") :css("background", "black") :css("border-radius", "50%") :css("padding", padSize.."px") :wikitext(abilityIcon) abilityIcon = tostring(iconSpan) result = abilityIcon if not icononly then result = abilityIcon .. " [[" ..linkText.. "|" ..displayText.. "]]" end return result end return p