Module:BattleTeam: Difference between revisions

From Cassette Beasts
Solari (talk | contribs)
No edit summary
Solari (talk | contribs)
No edit summary
Line 14: Line 14:
if #type_specified <= 1 then
if #type_specified <= 1 then
cell:addClass(frame:callParserFunction('#invoke', 'Database', 'get_type', move, 'elemental_type') .. "_type")
cell:addClass(frame:callParserFunction('#invoke', 'Database', 'get_move', move, 'elemental_type') .. "_type")
:wikitext(frame:callParserFunction('#invoke', 'Database', 'get_link', 'move', move))
:wikitext(frame:callParserFunction('#invoke', 'Database', 'get_link', 'move', move))
else  
else  

Revision as of 21:45, 13 September 2026

Documentation for this module may be created at Module:BattleTeam/doc

local p = {}

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(cell))
	end
	
	return table.concat(result)
end

return p