This module depends on the following other modules:
Module:State trait/List
Module:Tooltip
This module is similar to {{State trait}} but for modules.
It is intended for use in building state information tables. Passing it a English localized state trait name creates a {{collapse list}} with the state trait icon and name as the header and modifiers as the list.
--
-- Module:State trait
--
-- For use with Module:State, it builds a collapse list with state trait icon, name, and effects
--
local p = {};
local getArgs = require('Module:Arguments').getArgs
local lister = require('Module:Tooltip').effectList
function p.main(frame)
local args = getArgs(frame)
return p.state_trait(args[1], args[2])
end
function p.state_trait(trait, width)
-- ensure width is a number, defaults to 30px
width = type(width) == 'number' and width or 30
local trait_data = mw.loadData('Module:State trait/List')[trait]
-- return error message if not found
if not trait_data then
return '<span style="color:red; font-size:11px;">(unrecognized trait "' .. trait .. '" for [[Module:State trait]])</span>[[Category:Pages with unrecognized state traits]]'
end
local icon = mw.ustring.format("[[File:State trait %s.png|%spx|link=State traits#%s]] %s", trait_data['icon'],width,trait,trait)
-- long bracket string allows including literal newlines as well as both single and double quotes
local s = mw.ustring.format([[<div class="mw-collapsible mw-collapsed">'''%s'''<span style="visibility:hidden;color:transparent;"> </span>
<div class="mw-collapsible-content">]], icon)
s = s .. lister(trait_data['effect'], { listStyle="newline", indent="**", color={css=1}}) .. "\n</div></div>"
return s
end
return p