Module:IconBar

From Minetest
Revision as of 09:44, 7 June 2022 by >FnControlOption (FnControlOption changed the content model of the page Module:IconBar from "plain text" to "Scribunto")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:IconBar/doc

local p = {}

local makeInvokeFunc = require("Module:Arguments").makeInvokeFunc

function p._bar(args)
    local name = args.name
    local num = tonumber(args[1]) or 1
    if num == 0 then
        return "[[File:Empty " .. name .. ".png|16px]]"
    end
    local numFloor = math.floor(num)
    local s = string.rep("[[File:" .. name .. ".png|16px]]", numFloor)
    if numFloor ~= num then
        s = s .. "[[File:Half " .. name .. ".png|16px]]"
    end
    return s
end

p.bar = makeInvokeFunc(p._bar, {inherited = true})

return p