Module:Infobox Monster/sandbox
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Module:Infobox Monster/sandbox/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Infobox Monster/sandbox/doc. [edit]
Module:Infobox Monster/sandbox's function main is invoked by Template:Infobox Monster/sandbox.
Module:Infobox Monster/sandbox requires Module:InfoboxBuilder.
Module:Infobox Monster/sandbox requires Module:Yesno.
local InfoboxBuilder = require('Module:InfoboxBuilder')
local yesno = require('Module:Yesno')
local p = {}
function format_bool(value)
if value ~= nil then
return value and "Yes" or "No"
end
end
function image(value)
if value then
return "[[File:"..value.."|300px]]"
end
end
function categories(args)
local ret = {}
local notdefined = {
image = "Needs monster image",
power_level = "Needs power level information",
health = "Needs health information",
weakness = "Needs weakness information",
resistance = "Needs resistance information",
aggressive = "Needs aggression information"
}
for n, v in pairs(notdefined) do
if args[n] == nil then
table.insert(ret, v)
end
end
for i, v in ipairs(ret) do
if (v ~= '') then
ret[i] = string.format('[[Category:%s]]',v)
end
end
return table.concat(ret, "")
end
function p.main(frame)
local args = frame:getParent().args
local pagename = mw.title.getCurrentTitle().fullText
local ret = InfoboxBuilder()
:title(args.name or pagename)
:image({image=image(args.image)})
:row({label="Location", value=args.location or "?"})
:header("Combat")
:row({label="[[Power Level]]", value=args.power_level or "?"})
:row({label="[[Health]]", value=args.health or "?"})
:row({label="Weakness", value=args.weakness or "?"})
:row({label="Resistance", value=args.resistance or "?"})
:row({label="Aggressive", value=format_bool(yesno(args.aggressive)) or "?"})
:done()
if mw.title.getCurrentTitle().namespace == 0 then
ret:wikitext(categories(args))
end
return ret
end
return p