Toggle search
Search
Toggle menu
Join us on Discord!
Notifications
Toggle personal menu
Editing
Module:SpriteFile
From WoopMC
Views
Read
Edit
View history
associated-pages
Module
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Advanced
Special characters
Help
Heading
Level 2
Level 3
Level 4
Level 5
Format
Insert
Latin
Latin extended
IPA
Symbols
Greek
Greek extended
Cyrillic
Arabic
Arabic extended
Hebrew
Bangla
Tamil
Telugu
Sinhala
Devanagari
Gujarati
Thai
Lao
Khmer
Canadian Aboriginal
Runes
Á
á
À
à
Â
â
Ä
ä
Ã
ã
Ǎ
ǎ
Ā
ā
Ă
ă
Ą
ą
Å
å
Ć
ć
Ĉ
ĉ
Ç
ç
Č
č
Ċ
ċ
Đ
đ
Ď
ď
É
é
È
è
Ê
ê
Ë
ë
Ě
ě
Ē
ē
Ĕ
ĕ
Ė
ė
Ę
ę
Ĝ
ĝ
Ģ
ģ
Ğ
ğ
Ġ
ġ
Ĥ
ĥ
Ħ
ħ
Í
í
Ì
ì
Î
î
Ï
ï
Ĩ
ĩ
Ǐ
ǐ
Ī
ī
Ĭ
ĭ
İ
ı
Į
į
Ĵ
ĵ
Ķ
ķ
Ĺ
ĺ
Ļ
ļ
Ľ
ľ
Ł
ł
Ń
ń
Ñ
ñ
Ņ
ņ
Ň
ň
Ó
ó
Ò
ò
Ô
ô
Ö
ö
Õ
õ
Ǒ
ǒ
Ō
ō
Ŏ
ŏ
Ǫ
ǫ
Ő
ő
Ŕ
ŕ
Ŗ
ŗ
Ř
ř
Ś
ś
Ŝ
ŝ
Ş
ş
Š
š
Ș
ș
Ț
ț
Ť
ť
Ú
ú
Ù
ù
Û
û
Ü
ü
Ũ
ũ
Ů
ů
Ǔ
ǔ
Ū
ū
ǖ
ǘ
ǚ
ǜ
Ŭ
ŭ
Ų
ų
Ű
ű
Ŵ
ŵ
Ý
ý
Ŷ
ŷ
Ÿ
ÿ
Ȳ
ȳ
Ź
ź
Ž
ž
Ż
ż
Æ
æ
Ǣ
ǣ
Ø
ø
Œ
œ
ß
Ð
ð
Þ
þ
Ə
ə
Formatting
Links
Headings
Lists
Files
Discussion
Description
What you type
What you get
Italic
''Italic text''
Italic text
Bold
'''Bold text'''
Bold text
Bold & italic
'''''Bold & italic text'''''
Bold & italic text
local p = {} function p.sprite( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCurrentFrame() end -- Default settings local default = { scale = 1, size = 16, align = 'text-top' } local id = mw.text.trim( tostring( args[1] or '' ) ) if not args.keepcase then id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' ) 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 name = args.name if name == 'InvSprite' then name = 'Invicon' end local file = name .. ' ' .. id .. '.png' local altText = file .. ': Sprite image for ' .. id .. ' in Minecraft' if link ~= '' then altText = altText .. ' linking to ' .. link end if id == '' then file = 'Grid Unknown.png' altText = 'Unknown sprite image' end local sprite = mw.html.create( 'span' ):addClass( 'sprite-file' ) local img = '[[File:' .. 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( 'Module: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 return p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local
p
=
{
}
function
p
.
sprite
(
f
)
local
args
=
f
if
f
==
mw
.
getCurrentFrame
(
)
then
args
=
require
(
'Module:ProcessArgs'
)
.
merge
(
true
)
else
f
=
mw
.
getCurrentFrame
(
)
end
-- Default settings
local
default
=
{
scale
=
1
,
size
=
16
,
align
=
'text-top'
}
local
id
=
mw
.
text
.
trim
(
tostring
(
args
[
1
]
or
''
)
)
if
not
args
.
keepcase
then
id
=
mw
.
ustring
.
lower
(
id
)
:
gsub
(
'[%s%+]'
,
'-'
)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0
0
0
1:0
Summary:
Please note that all contributions to WoopMC may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
WoopMC:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Debug console
* The module exports are available as the variable "p", including unsaved modifications. * Precede a line with "=" to evaluate it as an expression or use print(). Use mw.logObject() for tables. * Use mw.log() and mw.logObject() in module code to send messages to this console.
Template:Documentation header
(
edit
)
Template:Template link general
(
edit
)
Template:Template link general
(
edit
)
Module:Arguments
(
edit
)
Module:SpriteFile/doc
(
edit
)
Module:Template link general
(
edit
)