Module:Inventory slot: Difference between revisions

Jump to navigation Jump to search
m
Hoping
(Direct copy paste from the Minecraft wiki)
 
m (Hoping)
Line 3: Line 3:
local i18n = {
local i18n = {
filename = 'Invicon $1',
filename = 'Invicon $1',
legacyFilename = 'Grid $1.png',
gm4Filename = 'Gm4icon $1',
modLink = 'Mods/$1/$2',
modLink = '$1/$2',
moduleAliases = [[Module:Inventory slot/Aliases]],
invAliases = [[Module:Inventory slot/Aliases]],
moduleRandom = [[Module:Random]],
gm4Aliases = [[Module:Gm4Sprite/Aliases]],
-- is random really necessary?
--moduleRandom = [[Module:Random]],
-- List of special prefixes which should be handled by
-- List of special prefixes which should be handled by
-- other modules (such as being moved outside links)
-- other modules (such as being moved outside links)
Line 14: Line 16:
damaged = 'Damaged',
damaged = 'Damaged',
unwaxed = 'Unwaxed',
unwaxed = 'Unwaxed',
},
suffixes = {
be = 'BE',
lce = 'LCE',
},
},
}
}
Line 23: Line 21:


local random = require( i18n.moduleRandom ).random
local random = require( i18n.moduleRandom ).random
local aliases = mw.loadData( i18n.moduleAliases )
local aliases = mw.loadData( i18n.invAliases )
local pageName = mw.title.getCurrentTitle().text
local pageName = mw.title.getCurrentTitle().text


Line 101: Line 99:
local title = frame.title or mw.text.trim( args.title or '' )
local title = frame.title or mw.text.trim( args.title or '' )
local mod = frame.mod
local mod = frame.mod
local module = frame.module
local name = frame.name or ''
local name = frame.name or ''
local num = frame.num
local num = frame.num
Line 107: Line 106:
local img
local img
if mod then
if mod then
img = i18n.legacyFilename:gsub( '%$1', name .. ' (' .. mod .. ')' )
if name:match( '%.gif$' ) or name:match( '%.png$' ) then
img = i18n.gm4Filename:gsub( '%$1', name .. ' (' .. module .. ')' )
name = name:sub( 0, -5 )
else
img = i18n.gm4Filename:gsub( '%$1', name .. ' (' .. module .. ').png' )
end
elseif name:match( '%.gif$' ) or name:match( '%.png$' ) then
elseif name:match( '%.gif$' ) or name:match( '%.png$' ) then
img = i18n.filename:gsub( '%$1', name )
img = i18n.filename:gsub( '%$1', name )
Line 120: Line 124:
if link == '' then
if link == '' then
if mod then
if mod then
link = i18n.modLink:gsub( '%$1', mod ):gsub( '%$2', name )
if module ~= nil then
end
link = i18n.modLink:gsub( '%$1', module ):gsub( '#%$2', name )
else
else
link = name:gsub( '^' .. i18n.prefixes.damaged .. ' ', '' )
--link = name:gsub( '^' .. i18n.prefixes.damaged .. ' ', '' )
for _, suffix in pairs( i18n.suffixes ) do
--for _, suffix in pairs( i18n.suffixes ) do
link = link:gsub( ' ' .. suffix .. '$', '' )
-- link = link:gsub( ' ' .. suffix .. '$', '' )
end
--end
link = nil
-- no non-gm4 default links
end
end
elseif link:lower() == 'none' then
elseif link:lower() == 'none' then
Line 157: Line 166:
item:attr{
item:attr{
['data-minetip-title'] = formattedTitle,
['data-title'] = formattedTitle,
['data-minetip-text'] = description
['data-lore'] = description
}
}
Line 178: Line 187:
:wikitext( '[[File:', img, '|32x32px|link=', link or '', '|alt=', altText, '|', escapedTitle, ']]' )
:wikitext( '[[File:', img, '|32x32px|link=', link or '', '|alt=', altText, '|', escapedTitle, ']]' )
if num and num > 1 and num < 1000 then
if num and (num:match( ',(%?)' ) or (num > 1 and num < 1000)) then
if link then
if link then
item:wikitext( '[[', link, '|' )
item:wikitext( '[[', link, '|' )
end
end
local number = item
local number = item
:tag( 'span' )
:tag( 'span' )
:addClass( 'invslot-stacksize' )
:addClass( 'invslot-stacksize' )
:attr{ title = plainTitle }
:attr{ title = plainTitle }
:wikitext( num )
:wikitext( num )
if args.numstyle then
if args.numstyle then
number:cssText( args.numstyle )
number:cssText( args.numstyle )
end
end
if link then
if link then
item:wikitext( ']]' )
item:wikitext( ']]' )
end
end
end
end
Line 213: Line 222:
local modData = {
local modData = {
aliases = args.modaliases or '',
aliases = args.modaliases or '',
atlas = args.modatlas or '',
default = args.mod
default = args.mod
}
}
if modData.aliases ~= '' then
modData.aliases = mw.loadData( 'Module:' .. modData.aliases )
-- just gonna hardcode this for now
else
if args.mod == 'gm4' then
modData.aliases = nil
modData.mod = 'gm4'
end
modData.atlas = mw.loadData( 'Module:Gm4Sprite' )
if args.mod == '' then
modData.aliases = mw.loadData( 'Module:Gm4Sprite/Aliases' )
elseif args.mod == '' then
modData.default = nil
modData.default = nil
end
end
Line 307: Line 318:
if frame.mod then
if frame.mod then
id = frame.mod .. ':' .. id
id = frame.mod .. ':' .. id
local section = modData.atlas.ids[id].section
frame.module = modData.atlas.sections[section].name
end
end
Line 396: Line 409:
expandedFrame.title = parentFrame.title or expandedFrame.title
expandedFrame.title = parentFrame.title or expandedFrame.title
expandedFrame.mod = parentFrame.mod or expandedFrame.mod
expandedFrame.mod = parentFrame.mod or expandedFrame.mod
expandedFrame.module = parentFrame.module or expandedFrame.module
expandedFrame.num = parentFrame.num or expandedFrame.num
expandedFrame.num = parentFrame.num or expandedFrame.num
expandedFrame.text = parentFrame.text or expandedFrame.text
expandedFrame.text = parentFrame.text or expandedFrame.text
Line 457: Line 471:
frame.name = frameText:sub( nameStart, ( frameText:find( '[,%[]', nameStart ) or 0 ) - 1 )
frame.name = frameText:sub( nameStart, ( frameText:find( '[,%[]', nameStart ) or 0 ) - 1 )
frame.num = math.floor( frameText:match( ',(%d+)' ) or 0 )
frame.num = frameText:match( ',(%?)' ) or math.floor( frameText:match( ',(%d+)' ) or 0 )
if frame.num == 0 then
if frame.num == 0 then
frame.num = nil
frame.num = nil
Bureaucrats, Check users, emailconfirmed, Interface administrators, staff, Administrators, translation-admin, Widget editors
1,659

edits

Navigation menu