Module:Lua banner: Difference between revisions

protect against "mw.title.new()" returns "nil"
 
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 47: Line 47:
boxArgs.text = 'This module depends on the following other modules:' .. moduleList
boxArgs.text = 'This module depends on the following other modules:' .. moduleList
else
else
boxArgs.text = 'This template  uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
boxArgs.text = 'This template  uses [[Chabadpedia:Lua|Lua]]:\n' .. moduleList
end
end
end
end
boxArgs.type = 'notice'
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.small = true
boxArgs.image = '[[File:Lua-Logo.svg|30px|alt=|link=]]'
boxArgs.image = '[[File:Lua-Logo.png|30px|alt=|link=]]'
return mMessageBox.main('mbox', boxArgs)
return mMessageBox.main('mbox', boxArgs)
end
end
Line 109: Line 109:
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
for i, module in ipairs(modules) do
for i, module in ipairs(modules) do
if module ~= "WP:libraryUtil" then
if module ~= "CP:libraryUtil" then
local moduleTitle = mw.title.new(module)
local moduleTitle = mw.title.new(module)
local moduleProt = moduleTitle and moduleTitle.protectionLevels["edit"][1]
local moduleProt = moduleTitle and moduleTitle.protectionLevels["edit"][1]