Ahora nos llamamos Minecraft Wiki Español
Le dimos un lavado de cara a la identidad de la wiki y al cómo nos identificaremos de ahora en adelante, ¡muchas gracias a los que participaron en la discusión!
Módulo:SpriteFile
Ir a la navegación
Ir a la búsqueda
Vanilla[editar código]
- Módulo:SpriteFile/AchievementSprite
- Módulo:SpriteFile/BiomeSprite
- Módulo:SpriteFile/BlockSprite
- Módulo:SpriteFile/EffectSprite
- Módulo:SpriteFile/EntitySprite
- Módulo:SpriteFile/EnvSprite
- Módulo:SpriteFile/FrontPageSprite
- Módulo:SpriteFile/Invicon
- Módulo:SpriteFile/ItemSprite
- Módulo:SpriteFile/NewAchievementSprite
Dungeons[editar código]
- Módulo:SpriteFile/DungeonsEntitySprite
- Módulo:SpriteFile/DungeonsItemSprite
- Módulo:SpriteFile/DungeonsEnchantmentSprite
Legends[editar código]
- Módulo:SpriteFile/LegendsEntitySprite
- Módulo:SpriteFile/LegendsMiscellaneousSprite
- Módulo:SpriteFile/LegendsStructureSprite
Story Mode[editar código]
Película[editar código]
[Ver | Editar | Purgar]La documentación arriba es transcluída desde Módulo:SpriteFile/doc.
local p = {} -- (Parte del código fue tomado de [[:pt:Módulo:SpriteFile]])
local i18n = {
moduloDiccionario = "Módulo:SpriteFile/$1", -- Nombre del módulo de traducción de sprites.
filename = '$1 $2.png', -- Nombre de los archivos. '$1' es el tipo de sprite; '$2' es el sprite.
}
function p.traducirNombre(modulo,nombre)
local frame = mw.getCurrentFrame()
local paginaModulo = i18n.moduloDiccionario:gsub( '%$1', modulo)
if pcall(function() mw.loadData(paginaModulo) end) then
local data = mw.loadData(paginaModulo)
if data and data.ids then
local lista = data.ids
if lista[nombre] then
return(lista[nombre])
end
end
end
return nil
end
function p.sprite( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Módulo:ProcessArgs' ).merge( true )
else
f = mw.getCurrentFrame()
end
-- Definiciones estándar
local default = {
scale = 1,
size = 16,
align = 'text-top'
}
local id = mw.text.trim( tostring( args[1] or args.id or '' ) )
local name = args.name
if not args.keepcase then
id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' )
end
if name == 'InvSprite' then
name = 'Invicon'
end
if p.traducirNombre(name,id) then
id = p.traducirNombre(name,id)
end
local link = ( args.link or '' )
if mw.ustring.lower( link ) == 'none' then
link = ''
elseif link ~= '' then
local linkPrefix = ( not link:find( '//' ) and args.linkprefix ) or ''
link = linkPrefix .. link
end
local scale = args.scale or default.scale
local height = ( args.height or args.size or default.size ) * scale
local width = ( args.width or args.size or default.size ) * scale
local size = width .. 'x' .. height .. 'px'
local styles = {}
if height ~= default.size then
styles[#styles + 1] = 'height:' .. height .. 'px'
end
if width ~= default.size then
styles[#styles + 1] = 'width:' .. width .. 'px'
end
local file = i18n.filename:gsub('%$1', name):gsub('%$2', id)
local altText = file .. ': Sprite de Imagen de ' .. id .. ' en Minecraft'
if link ~= '' then
altText = altText .. ' que conecta el ' .. link
end
if id == '' then
file = 'Grid Unknown.png'
altText = 'Imagen de sprite desconocida'
end
local sprite = mw.html.create( 'span' ):addClass( 'sprite-file' )
local img = '[[Archivo:' .. file .. '|' .. size .. '|link=' .. link .. '|alt=' .. altText .. '|class=pixel-image|' .. ( args.title or '' ) .. ']]'
sprite:node( img )
local align = args.align or default.align
if align ~= default.align then
styles[#styles + 1] = '--vertical-align:' .. align
end
styles[#styles + 1] = args.css
sprite:cssText( table.concat( styles, ';' ) )
local root
local spriteText
if args.text then
if not args['wrap'] then
root = mw.html.create( 'span' ):addClass( 'nowrap' )
end
spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext( args.text )
if args.title then
spriteText:attr( 'title', args.title )
end
if link ~= '' then
-- External link
if link:find( '//' ) then
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
else
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
end
end
end
if not root then
root = mw.html.create( '' )
end
root:node( sprite )
if spriteText then
root:node( spriteText )
end
return tostring( root )
end
function p.link( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Módulo:ProcessArgs' ).merge( true )
end
local link = args[1]
if args[1] and not args.id then
link = args[1]:match( '^(.-)%+' ) or args[1]
end
local text
if not args.notext then
text = args.text or args[2] or link
end
args[1] = args.id or args[1]
args.link = args.link or link
args.text = text
return p.sprite( args )
end
function p.doc( f )
local args = f
if f == mw.getCurrentFrame() then
args = f.args
else
f = mw.getCurrentFrame()
end
local dataPage = mw.text.trim(args[1])
if dataPage == "InvSprite" then
dataPage = "Invicon"
end
local data = mw.loadData( 'Módulo:SpriteFile/' .. dataPage)
local getProtection = function( title, action, extra )
local protections = { 'edit' }
if extra then
protections[#protections + 1] = extra
end
local addProtection = function( protection )
if protection == 'autoconfirmed' then
protection = 'editsemiprotected'
elseif protection == 'sysop' then
protection = 'editprotected'
end
protections[#protections + 1] = protection
end
local direct = title.protectionLevels[action] or {}
for _, protection in ipairs( direct ) do
addProtection( protection )
end
local cascading = title.cascadingProtection.restrictions[action] or {}
if #cascading > 0 then
protections[#protections + 1] = 'protect'
end
for _, protection in ipairs( cascading ) do
addProtection( protection )
end
return table.concat( protections, ',' )
end
local spriteStyle = ''
local dataTitle = mw.title.new( 'Módulo:' .. dataPage .. "/Aliases")
local dataProtection = getProtection( dataTitle, 'edit' )
local body = mw.html.create( 'div' ):attr( {
id = 'spritedoc',
['data-dataprotection'] = dataProtection,
['data-datatimestamp'] = f:callParserFunction( 'REVISIONTIMESTAMP', 'Módulo:' .. dataPage .. "/Aliases"),
['data-datapage'] = 'Módulo:' .. dataPage,
['data-spritesheet'] = nil,
['data-spriteprotection'] = nil,
['data-refreshtext'] = mw.text.nowiki( '{{#invoke:SpriteFile|doc|' .. dataPage .. '|refresh=1}}' ),
['data-settings'] = nil,
} )
local sections = {
{ name = 'Lista', id = 1},
}
for _, sectionData in ipairs(sections) do
local sectionTag = body:tag( 'div' ):addClass( 'spritedoc-section' ):attr( 'data-section-id', sectionData.id )
sectionTag:tag( 'b' ):wikitext( sectionData.name )
sections[sectionData.id] = { boxes = sectionTag:tag( 'ul' ):addClass( 'spritedoc-boxes' ) }
end
local keyedData = {}
local i = 1
for nombre, ID in pairs( data.ids ) do
keyedData[i] = {
sortKey = mw.ustring.lower(nombre),
name = nombre,
ID = ID
}
i = i + 1
end
table.sort( keyedData, function( a, b )
return a.sortKey < b.sortKey
end )
for _, data in ipairs( keyedData ) do
local idData = data.ID
local section = sections[1]
local idArchivo = p.traducirNombre(dataPage,idData) or idData
local archivo = dataPage.." "..idArchivo..".png"
local filePath = mw.getCurrentFrame():callParserFunction( 'filepath', archivo) or idData
local names = section[filePath]
if not names then
local box = section.boxes:tag( 'li' ):addClass( 'spritedoc-box' )
box:tag( 'div' ):addClass( 'spritedoc-image' )
:wikitext( p.sprite{id = idData, name = dataPage, keepcase = 1} )
names = box:tag( 'ul' ):addClass( 'spritedoc-names' )
section[filePath] = names
end
local nameElem = mw.html.create( 'li' ):addClass( 'spritedoc-name' )
local codeElem = nameElem:tag( 'code' ):wikitext( data.name )
names:wikitext( tostring( nameElem ) )
end
if args.refresh then
return '', '', tostring( body )
end
local styles = f:extensionTag( 'templatestyles', '', { src = 'Sprite/doc.css' } )
return styles, spriteStyle, tostring( body )
end
return p