Module:InventorySlot: Difference between revisions

Jump to navigation Jump to search
m
uhhh let's try this
(Add GM4RPSprite, which changes only the icons, but keeps gm4 aliases)
m (uhhh let's try this)
Line 117: Line 117:
end
end
return slot
return slot
end
-- Well Template:InventorySlot does not use any of the above code, so I'm going
-- to start brand new from here, with the Minecraft code
-- Based on work by the Minecraft wiki, https://minecraft.wiki
local i18n = {
filename = 'Invicon $1',
moduleAliases = [[Module:Inventory slot/Aliases]],
prefixes = {
any = 'Any',
matching = 'Matching',
damaged = 'Damaged',
unwaxed = 'Unwaxed',
},
}
function UISlot.makeItem( args )
local item = mw.html.create( 'span' ):addClass( 'invslot-item' )
if args.imgclass then
item:addClass( args.imgclass )
end
if frame.name == '' then
return item
end
local title = frame.title or mw.text.trim( args.title or '' )
local name = frame.name or ''
local count = frame.count
local description = frame.text
local img
if name:match( '%.gif$' ) or name:match( '%.png$' ) then
img = file:gsub( '%$1', name )
-- Remove file extension from name
name = il8n.filename:sub( 0, -5 )
else
-- Fall back to an individual image if the sprite is lacking
img = i18n.filename:gsub( '%$1', name .. '.png' )
end
local link = args.link or ''
if link == '' then
link = name:gsub( '^' .. i18n.prefixes.damaged .. ' ', '' )
for _, suffix in pairs( i18n.suffixes ) do
link = link:gsub( ' ' .. suffix .. '$', '' )
end
elseif link:lower() == 'none' then
link = nil
end
if link == pageName then
link = nil
end
local formattedTitle
local plainTitle
if title == '' then
plainTitle = name
elseif title:lower() ~= 'none' then
plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' )
local formatPattern = '&[0-9a-fk-or]'
if plainTitle:match( formatPattern ) then
formattedTitle = title
plainTitle = plainTitle:gsub( formatPattern, '' )
end
if plainTitle == '' then
plainTitle = name
else
plainTitle = plainTitle:gsub( '\', '\\' ):gsub( '&', '&' )
end
elseif link then
formattedTitle = ''
end
item:attr{
['data-title'] = formattedTitle,
['data-lore'] = description
}
item:addClass( 'invslot-item-image' )
:wikitext( '[[File:', img, '|32x32px|link=', link or '', '|alt=', altText, '|', escapedTitle, ']]' )
if count and count > 1 and count < 1000 then
if link then
item:wikitext( '[[', link, '|' )
end
local number = item
:tag( 'span' )
:addClass( 'invslot-stacksize' )
:attr{ title = plainTitle }
:wikitext( count )
if link then
item:wikitext( ']]' )
end
end
return item
end
function UISlot.slot( f )
local args = f.args or f
-- not really sure what this does
local args = f.args or f
if f == mw.getCurrentFrame() and args[1] == nil then
args = f:getParent().args
end
if not args.parsed then
args[1] = mw.text.trim( args[1] or '' )
end
-- uh, figure this out then update makeItem
--local frames
--if args.parsed then
-- frames = args[1]
--end
local body = mw.html.create( 'span' ):addClass( 'invslot' ):css{ ['vertical-align'] = args.align }
if animated then
body:addClass( 'animated' )
end
if args.class then
body:addClass( args.class )
end
if args.style then
body:cssText( args.style )
end
-- Figure out cycling here
-- until then, just use args instead of frame,i,args
local item = makeItem(args)
end
end


return UISlot
return UISlot
Bureaucrats, Check users, emailconfirmed, Interface administrators, staff, Administrators, translation-admin, Widget editors
1,659

edits

Navigation menu