Module:KnightMiner/DeprecatedSprites

Jump to navigation Jump to search

This module pulls a list of deprecated sprites from one of the sprite ID modules and displays it in a simply formatted fashion.

Usage[edit source]

To run p.deprecated, simply set the first parameter to the name of a sprite sheet; for example, Block

Example[edit source]

{{#invoke:KnightMiner/DeprecatedSprites|deprecated|Block}}

[view] [edit] [history] [refresh]The above documentation is transcluded from Module:KnightMiner/DeprecatedSprites/doc.
local p = {}
function p.deprecated( f )
	local name = f.args[1] .. 'Sprite'
	
	-- Load the list of sprites based on the name given
	local data = mw.loadData( 'Module:' .. name ).ids
	
	-- Go over every sprite to check for deprecated sprites
	local output = {}
	for k, v in pairs( data ) do
		if v.deprecated then
			table.insert( output, '<code>' .. k .. '</code>' )
		end
	end

	-- If we have results, then format them a bit and return results
	if #output > 0 then
		table.sort( output )

		-- Add a dummy item to make the list easier
		table.insert( output, 1, '' )

		local div = mw.html.create( 'div' ):css{
			        ['column-width'] = '15em',
			   ['-moz-column-width'] = '15em',
			['-webkit-column-width'] = '15em'
		}:wikitext( table.concat( output, '\n* ' ) )
		
		return '; [[Template:' .. name .. '|' .. name .. ']] \n' .. tostring( div )
	end
end

return p