Module:BattleTeam: Difference between revisions
From Cassette Beasts
No edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 8: | Line 8: | ||
return "Arguments found: " .. #argument_list | return "Arguments found: " .. #argument_list | ||
end | end | ||
local override = argument_list == 3 | local override = #argument_list == 3 | ||
local row = mw.html.create('tr') | local row = mw.html.create('tr') | ||
| Line 14: | Line 14: | ||
if not override then | if not override then | ||
if mon_type == nil then | if mon_type == nil or mon_type == "" then | ||
mon_type = frame:callParserFunction('#invoke', 'Database', 'get_species', frame.args[1], "elemental_type") | mon_type = frame:callParserFunction('#invoke', 'Database', 'get_species', frame.args[1], "elemental_type") | ||
end | end | ||
| Line 21: | Line 21: | ||
:attr('align', 'center') | :attr('align', 'center') | ||
:cssText('width: 108px; padding: 6px;') | :cssText('width: 108px; padding: 6px;') | ||
:wikitext("[[" .. frame:callParserFunction('#invoke', 'Database', 'get_species', frame.args[1], "name") .. ".png|80x42px]]") | :wikitext("[[File:" .. frame:callParserFunction('#invoke', 'Database', 'get_species', frame.args[1], "name") .. ".png|80x42px]]") | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
:attr('align', 'center') | :attr('align', 'center') | ||
:cssText('width: 108px; padding: 6px;') | :cssText('width: 108px; padding: 6px;') | ||
:wikitext(frame:callParserFunction('#invoke', 'Database', 'get_link', 'species', frame.args[1]) .. "<br/> | :wikitext(frame:callParserFunction('#invoke', 'Database', 'get_link', 'species', frame.args[1]) | ||
.. "<br/>" | |||
.. frame:expandTemplate({title = 'TypeButton', args = { mon_type }})) | |||
:allDone() | :allDone() | ||
else | else | ||
| Line 32: | Line 34: | ||
:attr('align', 'center') | :attr('align', 'center') | ||
:cssText('width: 108px; padding: 6px;') | :cssText('width: 108px; padding: 6px;') | ||
:wikitext("[[" .. argument_list[3] .. ".png|80x42px]]") | :wikitext("[[File:" .. argument_list[3] .. ".png|80x42px]]") | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
:attr('align', 'center') | :attr('align', 'center') | ||
:cssText('width: 108px; padding: 6px;') | :cssText('width: 108px; padding: 6px;') | ||
:wikitext(argument_list[2] .. "<br/> | :wikitext(argument_list[2] | ||
.. "<br/>" | |||
.. frame:expandTemplate({title = 'TypeButton', args = { argument_list[1] }})) | |||
:allDone() | :allDone() | ||
end | end | ||
Latest revision as of 00:51, 14 September 2026
Documentation for this module may be created at Module:BattleTeam/doc
local p = {}
function p.get_monster(frame)
local argument_list = mw.text.split(frame.args[1], ";", true)
local result = {}
if (#argument_list ~= 1) and (#argument_list ~= 3) then
return "Arguments found: " .. #argument_list
end
local override = #argument_list == 3
local row = mw.html.create('tr')
local mon_type = frame.args[2]
if not override then
if mon_type == nil or mon_type == "" then
mon_type = frame:callParserFunction('#invoke', 'Database', 'get_species', frame.args[1], "elemental_type")
end
row:tag('td')
:attr('align', 'center')
:cssText('width: 108px; padding: 6px;')
:wikitext("[[File:" .. frame:callParserFunction('#invoke', 'Database', 'get_species', frame.args[1], "name") .. ".png|80x42px]]")
:done()
:tag('td')
:attr('align', 'center')
:cssText('width: 108px; padding: 6px;')
:wikitext(frame:callParserFunction('#invoke', 'Database', 'get_link', 'species', frame.args[1])
.. "<br/>"
.. frame:expandTemplate({title = 'TypeButton', args = { mon_type }}))
:allDone()
else
row:tag('td')
:attr('align', 'center')
:cssText('width: 108px; padding: 6px;')
:wikitext("[[File:" .. argument_list[3] .. ".png|80x42px]]")
:done()
:tag('td')
:attr('align', 'center')
:cssText('width: 108px; padding: 6px;')
:wikitext(argument_list[2]
.. "<br/>"
.. frame:expandTemplate({title = 'TypeButton', args = { argument_list[1] }}))
:allDone()
end
table.insert(result, tostring(row))
return table.concat(result)
end
function p.get_moves(frame)
local move_list = mw.text.split(frame.args[1], ",", true)
local result = {}
for _, move in ipairs(move_list) do
local type_specified = mw.text.split(move, ";", true)
local row = mw.html.create('tr')
:attr('align', 'left')
local cell = row:tag('td')
:cssText('display: inline-block; line-height: 1.1em; background-repeat: no-repeat; background-position: calc(0% - 0.21em) center; background-size: 1.66em; padding-left: 1.75em; background-color: transparent;')
if #type_specified <= 1 then
cell:addClass(frame:callParserFunction('#invoke', 'Database', 'get_move', move, 'elemental_type') .. "_type")
:wikitext(frame:callParserFunction('#invoke', 'Database', 'get_link', 'move', move))
else
cell:addClass(type_specified[1] .. "_type")
:wikitext(type_specified[2])
end
cell:allDone()
table.insert(result, tostring(row))
end
return table.concat(result)
end
return p
