Module:Inventory slot: Difference between revisions

Add support for custom hex code colors
No edit summary
Tag: Reverted
(Add support for custom hex code colors)
 
(One intermediate revision by the same user not shown)
Line 120: Line 120:
else
else
-- 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 .. '.gif' ) or i18n.filename:gsub( '%$1', name .. '.png' )
img = i18n.filename:gsub( '%$1', name .. '.png' )
end
end
Line 193: Line 193:
plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' )
plainTitle = title:gsub( '\\\\', '\' ):gsub( '\\&', '&' )
local formatPattern = '&[0-9a-fk-or]'
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
formattedTitle = title
if plainTitle:match( formatPattern ) then
plainTitle = plainTitle:gsub( formatPattern, '' )
formattedTitle = title
plainTitle = plainTitle:gsub( formatPattern, '' )
end
end
end
Undo