Module:Cost
From Inkipedia, the Splatoon wiki
Displays an inline currency icon with a text link.
Usage
{{Cost|<game>|<price>|<currency>|<size>|<link>|<textwidth>}}
game
|
Unnamed, required | The game that the cost belongs to. Must be one of the following:
| |||
price
|
Unnamed, required (may be empty) | The quantity to show as the cost. If set empty, the template will show the icon only. Note that this template also accepts space (' ') which handles differently to empty. Use 0 or Free for free items.
| |||
currency
|
Unnamed, optional | The currency to use. The default value is cash .
| |||
Must be one of the following: | S | S2 | S3 | ||
cash |
|||||
pe |
|||||
sss |
|||||
ge |
|||||
sard |
|||||
ac |
|||||
cqp |
|||||
sl |
|||||
gsl |
|||||
bs |
|||||
ss |
|||||
gs |
|||||
mb |
|||||
pl |
|||||
size
|
Unnamed, optional | The icon size for the currency icon. The default is 24 .
| |||
link
|
Unnamed, optional | If present, the amount text will be a link to the currency's page. | |||
textwidth
|
Unnamed, optional | Requries size and link to both be present.If specified, the label will be set inside a right-aligned rectangle of the specified width |
Markup
*{{Cost|S|200}} *{{Cost|S2|200}} *{{Cost|S3|200}} *{{Cost|S|}} *{{Cost|S|1|sss}} *{{Cost|S2||ac}} *{{Cost|S3|160|bs}} *{{Cost|S|200|cash|48}} *{{Cost|S|200|cash|link}} *{{Cost|S|200|cash|48|link}} *{{Cost|S|200|cash|24|link|60}} *{{Cost|S|200|cash|24| |60}}
Output
local p = {} local iconModule = require('Module:Icon') local gameShortenedModule = require('Module:GameShortened') function p.main(frame) local args = frame:getParent().args return p.getCost(args) end function p.getCost(args) local game = gameShortenedModule.getGame(args['game'] or args[1]) local price = args['price'] or args[2] price = price and price ~= '' and price or nil -- set empty to nil local currency = args['currency'] or args[3] or 'cash' local size = args['size'] or args[4] or '24px' local isLink = args['link'] or args[5] isLink = isLink ~= nil and isLink ~= '' local textWidth = '' -- If specified, the label will be set inside a right-aligned rectangle of the specified width -- Switch and call p.getCostEx end function p.getCostEx(args) local group = args[1] local name = args[2] local size = args[3] local alt = string.format("%s %s", args[4], name .. pluralS) local customStyles = args[5] or '' local pluralS = args[6] and 's' or '' local textLink = string.format("[[%s|%s]]", name, alt) local iconArgs = { group = group, name = name, size = size, width = size, link = name, alt = alt } local icon = iconModule.getIcon(iconArgs) local result = icon .. " <span style=\"display: inline-block; " .. customStyles .. "\">" if alt ~= '' then result = result .. " " .. textLink elseif name ~= '' then result = result .. " " .. name end result = result .. pluralS .. "</span>" return result end return p