Difference between revisions of "Module:IconBar"
Jump to navigation
Jump to search
m (MrIbby moved page Module:Hearts to Module:IconBar without leaving a redirect) |
m |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
− | function p. | + | local getArgs = require("Module:Arguments").getArgs |
− | local num = tonumber( | + | |
+ | function p.bar(frame) | ||
+ | local args = getArgs(frame, {inherited = true}) | ||
+ | return p._bar(args) | ||
+ | end | ||
+ | |||
+ | function p._bar(args) | ||
+ | local name = args.name | ||
+ | local num = tonumber(args[1]) or 1 | ||
if num == 0 then | if num == 0 then | ||
− | return "[[File:Empty | + | return "[[File:Empty " .. name .. ".png|16px]]" |
end | end | ||
local numFloor = math.floor(num) | local numFloor = math.floor(num) | ||
− | local s = | + | local s = string.rep("[[File:" .. name .. ".png|16px]]", numFloor) |
− | |||
− | |||
− | |||
if numFloor ~= num then | if numFloor ~= num then | ||
− | s = s .. "[[File:Half | + | s = s .. "[[File:Half " .. name .. ".png|16px]]" |
end | end | ||
return s | return s |
Revision as of 16:02, 10 April 2017
local p = {}
local getArgs = require("Module:Arguments").getArgs
function p.bar(frame)
local args = getArgs(frame, {inherited = true}) return p._bar(args)
end
function p._bar(args)
local name = args.name local num = tonumber(args[1]) or 1 if num == 0 then return "16px" end local numFloor = math.floor(num) local s = string.rep("16px", numFloor) if numFloor ~= num then s = s .. "16px" end return s
end
return p