Módulo:Type

local Type ={}local data = mw.loadData('Module:Type/data')local layoutdata = mw.loadData('Module:Layout/data')localfunction isempty(s)-- Empty parameter checkreturn s ==nilor s ==''endfunction Type.type( frame )-- Implements {{Type}}-- This block calls the function _type, where the real magic happens.-- This part just determines if it's from an #invoke or a Template; it makes sure the arguments are filled accordingly.ifnot isempty( frame.args[1])thenreturn Type._type( frame.args )elsereturn Type._type( frame:getParent().args )endendfunction Type.chartkey( frame )-- Implements {{Type chart key}}endfunction Type._type( args )-- The reusable part of Type, so that it can be called as a function from other Modules.-- This first line throws an error when there's no first argument.assert( args[1],"There is no type listed.")local pokemontype = args[1]local fallbacktext ='[['..pokemontype..' type|<span style="color: #F8F8F8;">'..pokemontype..'</span>]]'local element = mw.html.create('span'):css('border-style','solid none'):css('border-width','1px'):css('border-radius','5px'):css('padding','0.15em'):css('font-variant','small-caps'):css('font-size','9pt'):css('color','#F8F8F8'):css('text-shadow','0px 1px 1px #807870'):css('background',data.color[string.lower(pokemontype)]):css('border-top-color',data.bordertopcolor[string.lower(pokemontype)]):css('border-bottom-color',data.borderbottomcolor[string.lower(pokemontype)]):wikitext( args[2]or fallbacktext ):allDone()returntostring(element)endfunction Type.color( frame )-- Implements {{Normal}}, etc. (the "Color templates").-- This really should just call data.color["Normal"] in other templates, and it will be much faster.-- The template code would be:-- <includeonly>{{invoke:Type|color|Normal}}</includeonly>-- <noinclude>{{invoke:Type|color|Normal|description}}[[Category:Color templates]]</noinclude>-- This first line throws an error when there's no first argument.assert( frame.args[1],"There is no type listed.")local pokemontype = frame.args[1]ifnot( frame.args[2]=="description")thenreturnstring.sub(data.color[string.lower(pokemontype)],2)elselocal T = mw.html.create('table'):tag('tr'):tag('th'):css('background',data.color[string.lower(pokemontype)]):css('font-size','small'):css('color','#FFFFFF'):wikitext('[['..pokemontype..' Pokémon|<span style="color:#FFFFFF">'..pokemontype..'</span>]] color:'):done():tag('td'):tag('span'):css('font-weight','bold'):css('color',data.color[string.lower(pokemontype)]):wikitext(string.sub(data.color[string.lower(pokemontype)],2)):allDone()returntostring(T)endendreturn Type