Module:Inventory slot: Difference between revisions

m
Reverted edits by Diamondback88 (talk) to last revision by [[User:minecraft>MarkusRost|minecraft>MarkusRost]]
No edit summary
Tag: Reverted
m (Reverted edits by Diamondback88 (talk) to last revision by [[User:minecraft>MarkusRost|minecraft>MarkusRost]])
Tags: Rollback Reverted
Line 3: Line 3:
local i18n = {
local i18n = {
filename = 'Invicon $1',
filename = 'Invicon $1',
-- legacyFilename = 'Grid $1.png',
legacyFilename = 'Grid $1.png',
legacyFilename = '$1Invicon $2.png',
modLink = 'Mods/$1/$2',
-- modLink = 'Mods/$1/$2',
modLink = '$1:$2',
moduleAliases = [[Module:Inventory slot/Aliases]],
moduleAliases = [[Module:Inventory slot/Aliases]],
moduleParallelAliases = [[Module:ParallelAliases]],
moduleRandom = [[Module:Random]],
moduleRandom = [[Module:Random]],
-- List of special prefixes which should be handled by
-- List of special prefixes which should be handled by
Line 16: Line 13:
matching = 'Matching',
matching = 'Matching',
damaged = 'Damaged',
damaged = 'Damaged',
-- parallel = 'Parallel', -- added
},
},
suffixes = {
suffixes = {
Line 27: Line 23:
local random = require( i18n.moduleRandom ).random
local random = require( i18n.moduleRandom ).random
local aliases = mw.loadData( i18n.moduleAliases )
local aliases = mw.loadData( i18n.moduleAliases )
local parallelAliases = mw.loadData( i18n.moduleParallelAliases )
local pageName = mw.title.getCurrentTitle().text
local pageName = mw.title.getCurrentTitle().text


Line 104: Line 99:
local category
local category
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 mod = frame.mod  -- <----- THIS IS CHANGED
local name = frame.name or ''
local name = frame.name or ''
local num = frame.num
local num = frame.num
Line 112: Line 106:
local img
local img
if mod then
if mod then
-- img = i18n.legacyFilename:gsub( '%$1', name .. ' (' .. mod .. ')' )
img = i18n.legacyFilename:gsub( '%$1', name .. ' (' .. mod .. ')' )
img = i18n.legacyFilename:gsub( '%$1', mod ):gsub( '%$2', name )  -- <---- this is also different
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 122: Line 115:
img = i18n.filename:gsub( '%$1', name .. '.png' )
img = i18n.filename:gsub( '%$1', name .. '.png' )
end
end
-- local link = args.link or ''
-- if link == '' then
-- if mod then
-- link = i18n.modLink:gsub( '%$1', mod ):gsub( '%$2', name )
-- else
-- link = name:gsub( '^' .. i18n.prefixes.damaged .. ' ', '' )
-- for _, suffix in pairs( i18n.suffixes ) do
-- link = link:gsub( ' ' .. suffix .. '$', '' )
-- end
-- end
-- elseif link:lower() == 'none' then
-- link = nil
-- end
-- if link == pageName then
-- link = nil
-- end
local link = args.link or ''
local link = args.link or ''
if link == '' then
if link == '' then
if mod then   -- <----- this if statement is edited too
if mod then
if mod == "parallel" then
link = i18n.modLink:gsub( '%$1', mod ):gsub( '%$2', name )
link = name
else
link = i18n.modLink:gsub( '%$1', mod ):gsub( '%$2', name )
end
else
else
link = "Vanilla:" .. 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 .. '$', '' )
Line 250: Line 222:
modData.default = nil
modData.default = nil
end
end
-- if mod == 'parallel' then  -- <------ THIS IS NEW
-- modData.aliases = mw.loadData( 'Module:ParallelAliases' )
-- end
local frames
local frames
Line 335: Line 304:
if aliases or modData.aliases then
if aliases or modData.aliases then
local id = frame.name
local id = frame.name
-- if frame.mod then
if frame.mod then
-- id = frame.mod .. ':' .. id
id = frame.mod .. ':' .. id
-- end
end
if frame.mod then -- <--- THIS IS CHANGED
if frame.mod == 'parallel' then
modData.aliases = parallelAliases
else
id = frame.mod .. ':' .. id
end
end
local alias = modData and modData.aliases and modData.aliases[id] or
local alias = modData and modData.aliases and modData.aliases[id] or