Module:HPBar
Cached copy of the original page · revision 1391289 · refresh
| Main | Documentation | Usage |

This Lua module is used primarily on pages in the Main namespace. It can be found on 974 pages, or on about 7.32% of those pages.
Edits to this Lua module will be widely noticed. To avoid large-scale disruption and unnecessary server load, any changes to this Lua module should be tested in its sandbox or testcases subpages. The tested changes can then be added to this page in one single edit by an administrator or Content Moderator.
Please consider discussing any changes in the wiki's Discord.
Module for {{HPBar}}.
local p = {}
local lib = require('Module:Feature')
local yesno = require('Module:Yesno')
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
parentFirst = true,
wrapper = { 'Template:HPBar' }
})
return p._main(args)
end
function p._main(args)
local gaugeStr = args[1] or "0"
local isOver10 = args.isOver10 or false
local size = args.size or 15
if yesno(isOver10) then
size = args.size or 20
end
local link = args.link or ""
-- Split to individual characters. e.g. 123 -> { 1, 2, 3 }
local gauges = lib.split(gaugeStr, "")
local node_result = mw.html.create()
local file = ""
for i = 1, #gauges, 1 do
if yesno(isOver10) then
file = file .. '[[File:Lifebar10_' .. gauges[i] .. '.png|' .. size .. 'px|link=' .. link .. ']]'
else
file = file .. '[[File:Lifebar' .. gauges[i] .. '.png|' .. size .. 'px|link=' .. link .. ']]'
end
end
node_result
:tag('span')
:addClass('DropShadow')
:wikitext(file)
:done()
return node_result
end
return p;