Модуль:Item icon
Для документации этого модуля может быть создана страница Модуль:Item icon/doc
local p = {}
local cargo = mw.ext.cargo
local quality = {
['Мусор'] = 'junk',
['мусор'] = 'junk',
['Обычный'] = 'common',
['обычный'] = 'common',
['Необычный'] = 'uncommon',
['необычный'] = 'uncommon',
['Редкий'] = 'rare',
['редкий'] = 'rare',
['Эпический'] = 'epic',
['эпический'] = 'epic',
['Легендарный'] = 'legendary',
['легендарный'] = 'legendary',
['Мифический'] = 'mythic',
['мифический'] = 'mythic',
['Предмет задачи'] = 'quest',
['предмет задачи'] = 'quest',
['Задача'] = 'quest',
['задача'] = 'quest'
}
local function switchString(str1, str2)
local ret = ""
if str2 == nil then
ret = str1
else
if str2 == '' then
ret = str1
else
ret = str2
end
end
return ret
end
function p.Main( frame )
local text = ""
tables = 'Items'
fields = '_pageName,icon,name,quality'
local args = {
where = '_pageName = "' .. frame.args[1] .. '"',
groupBy = '_pageName',
limit = 1,
}
local result = cargo.query( tables, fields, args )
local r = result[1]
if r == nil then
local innertext = frame.args[1]
if frame.args[2] == "Обычный" or frame.args[2] == "обычный" then
innertext = frame.args[1]
elseif frame.args[2] == "Необычный" or frame.args[2] == "необычный" then
innertext = frame.args[1]
elseif frame.args[2] == "Редкий" or frame.args[2] == "редкий" then
innertext = frame.args[1]
elseif frame.args[2] == "Эпический" or frame.args[2] == "эпический" then
innertext = frame.args[1]
elseif frame.args[2] == "Легендарный" or frame.args[2] == "легендарный" then
innertext = frame.args[1]
elseif frame.args[2] == "Мифический" or frame.args[2] == "мифический" then
innertext = frame.args[1]
elseif frame.args[2] ~= "" then
innertext = frame.args[2]
end
text = '[['..frame.args[1]..'|<span class="ajaxttlink">'..innertext..'</span>]]'
else
if r['name'] ~= "" then
icon = '<span style="display:inline-block;overflow:hidden;width:20px;height:20px;vertical-align:middle;margin-left:-1pt;">[[Файл:' .. r['icon'] .. '|20px|bottom|ссылка=' .. r['_pageName'] .. ']]</span>'
else
icon = '[[Файл:' .. r['icon'] .. '|20px|ссылка=' .. r['_pageName'] .. ']]'
end
local innertext = r['_pageName']
if frame.args[2] == "Обычный" or frame.args[2] == "обычный" then
innertext = r['_pageName']
elseif frame.args[2] == "Необычный" or frame.args[2] == "необычный" then
innertext = r['_pageName']
elseif frame.args[2] == "Редкий" or frame.args[2] == "редкий" then
innertext = r['_pageName']
elseif frame.args[2] == "Эпический" or frame.args[2] == "эпический" then
innertext = r['_pageName']
elseif frame.args[2] == "Легендарный" or frame.args[2] == "легендарный" then
innertext = r['_pageName']
elseif frame.args[2] == "Мифический" or frame.args[2] == "мифический" then
innertext = r['_pageName']
elseif frame.args[2] ~= "" then
innertext = frame.args[2]
end
local item_quality = {}
if frame.args[2] == "Обычный" or frame.args[2] == "обычный" then
item_quality = 'common'
elseif frame.args[2] == "Необычный" or frame.args[2] == "необычный" then
item_quality = 'uncommon'
elseif frame.args[2] == "Редкий" or frame.args[2] == "редкий" then
item_quality = 'rare'
elseif frame.args[2] == "Эпический" or frame.args[2] == "эпический" then
item_quality = 'epic'
elseif frame.args[2] == "Легендарный" or frame.args[2] == "легендарный" then
item_quality = 'legendary'
elseif frame.args[2] == "Мифический" or frame.args[2] == "мифический" then
item_quality = 'mythic'
else
item_quality = quality[r['quality']]
end
text = icon .. ' <span class="itemname ' .. item_quality .. '">[[['.. r['_pageName'] .. '|<span class="ajaxttlink ">' .. innertext ..'</span>]]]</span>'
end
return text
end
return p