Module:Infobox Ranged Weapon Group
Module documentation
This documentation is transcluded from Template:No documentation/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Infobox Ranged Weapon Group/doc. [edit]
Module:Infobox Ranged Weapon Group's function main is invoked by Template:Infobox Ranged Weapon Group.
Module:Infobox Ranged Weapon Group requires Module:Infobox.
-- Module for [[Template:Infobox Ranged Weapon Group]]
local p = {}
local infobox = require('Module:Infobox')
-- Format attack speed
function attackspeedarg(arg)
if not infobox.isDefined(arg) then
return nil
end
local lowarg = string.lower(arg)
local numarg = tonumber(arg)
if lowarg == 'no' or lowarg == 'n/a' then
return 'N/A'
elseif lowarg == 'varies' or lowarg == 'random' then
return '<span title="Weapons in this group have a variable attack speed." style="cursor:help; border-bottom:1px dotted;">Variable</span>'
end
if numarg ~= nil then
return string.format('%s %s (%.1f seconds)', numarg, (numarg > 1) and 'ticks' or 'tick', numarg * 0.6)
end
end
-- Main function called with invokes
function p.main(frame)
local args = frame:getParent().args
local ret = infobox.new(args)
ret:defineParams{
{ name = 'name', func = 'name' },
{ name = 'images', func = 'has_content' },
{ name = 'ammunition', func = 'has_content' },
{ name = 'twohanded', func = 'has_content' },
{ name = 'speed', func = attackspeedarg },
}
ret:defineLinks({ hide = true })
ret:create()
ret:cleanParams()
ret:defineName('Infobox Ranged Weapon Group')
ret:addRow{
{ tag = 'argh', content = 'name', class='infobox-header', colspan = '20' }
}
ret:pad(20)
ret:addRow{
{ tag = 'argd', content = 'images', class='infobox-image', colspan = '20' }
}
ret:pad(20)
ret:addRow{
{ tag = 'th', content = '[[Ammunition]]', colspan = '7' },
{ tag = 'argd', content = 'ammunition', colspan = '13' }
}
ret:addRow{
{ tag = 'th', content = 'Two handed?', colspan = '7' },
{ tag = 'argd', content = 'twohanded', colspan = '13' }
}
ret:pad(20)
ret:addRow{
{ tag = 'th', content = '[[Attack speed]]', class = 'infobox-subheader', colspan = '20' }
}
ret:pad(20)
ret:addRow{
{ tag = 'argd', content = 'speed', colspan = '20', class = 'infobox-full-width-content' }
}
ret:pad(20)
return ret:tostring()
end
return p