Module:Inventory slot: Difference between revisions
m 58 revisions imported |
Port: zh:Special:Diff/1046108 |
||
| Line 115: | Line 115: | ||
-- Fall back to an individual image if the sprite is lacking | -- Fall back to an individual image if the sprite is lacking | ||
img = i18n.filename:gsub( '%$1', name .. '.png' ) | img = i18n.filename:gsub( '%$1', name .. '.png' ) | ||
end | |||
if name:match( ' Revision %d+' ) then | |||
name = name:gsub( ' Revision %d+', '' ) | |||
end | end | ||
| Line 141: | Line 145: | ||
plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' ) | plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' ) | ||
local | local formatPatterns = {'&[0-9a-jl-qs-vyzr]', '&#%x%x%x%x%x%x', '&$%x%x%x'} | ||
if plainTitle:match( formatPattern ) then | for _, formatPattern in ipairs( formatPatterns ) do | ||
if plainTitle:match( formatPattern ) then | |||
formattedTitle = title | |||
plainTitle = plainTitle:gsub( formatPattern, '' ) | |||
end | |||
end | end | ||
| Line 173: | Line 179: | ||
altText = altText .. ' ' .. description:gsub( '/', ' ' ) | altText = altText .. ' ' .. description:gsub( '/', ' ' ) | ||
end | end | ||
altText = altText:gsub( '&[0-9a- | altText = altText:gsub( '&[0-9a-jl-qs-wr]', '' ) | ||
end | end | ||
item:addClass( 'invslot-item-image' ) | item:addClass( 'invslot-item-image' ) | ||
| Line 259: | Line 265: | ||
if frame[1] then | if frame[1] then | ||
item = body:tag( 'span' ):addClass( 'animated-subframe' ) | item = body:tag( 'span' ):addClass( 'animated-subframe' ) | ||
local subActiveFrame = frame.randomise and random( #frame ) or 1 | local subActiveFrame = frame.randomise == true and random( #frame ) or 1 | ||
for sI, sFrame in ipairs( frame ) do | for sI, sFrame in ipairs( frame ) do | ||
local sItem = makeItem( sFrame, sI, args ) | local sItem = makeItem( sFrame, sI, args ) | ||
| Line 347: | Line 353: | ||
-- or the subframe being the only frame | -- or the subframe being the only frame | ||
if #subframes == 1 or #splitFrames == i and #frames == 0 then | if #subframes == 1 or #splitFrames == i and #frames == 0 then | ||
local lastFrame = #frames | |||
mergeList( frames, subframes ) | mergeList( frames, subframes ) | ||
-- Inherit the randomise flag if it's the only frame | |||
if #splitFrames == 1 then | |||
frames.randomise = subframes.randomise | |||
end | |||
-- Append alias reference data, if present | |||
if aliasReference and subframes.aliasReference then | |||
if not expandedAliases then | |||
expandedAliases = {} | |||
end | |||
for i, aliasRefData in pairs(subframes.aliasReference) do | |||
expandedAliases[lastFrame + i] = aliasRefData | |||
end | |||
end | |||
else | else | ||
table.insert( frames, subframes ) | table.insert( frames, subframes ) | ||
| Line 356: | Line 378: | ||
else | else | ||
-- Randomise starting frame for "Any *" aliases, as long as the alias is the only frame | -- Randomise starting frame for "Any *" aliases, as long as the alias is the only frame | ||
if frames.randomise = | if frames.randomise ~= 'never' and frame.name:match( '^' .. i18n.prefixes.any .. ' ' ) then | ||
frames.randomise = true | frames.randomise = true | ||
else | |||
frames.randomise = false | frames.randomise = false | ||
end | end | ||