Для документации этого модуля может быть создана страница Модуль:Item icon/doc
local p = {}
local cargo = mw.ext.cargo
local quality = {
['мусор'] = 'junk',
['обычный'] = 'common',
['необычный'] = 'uncommon',
['редкий'] = 'rare',
['эпический'] = 'epic',
['легендарный'] = 'legendary',
['мифический'] = '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 mw.ustring.lower(frame.args[2]) == "quest" then
innertext = frame.args[1]
elseif mw.ustring.lower(frame.args[2]) == "задача" then
innertext = frame.args[1]
elseif mw.ustring.lower(frame.args[2]) == "обычный" then
innertext = frame.args[1]
elseif mw.ustring.lower(frame.args[2]) == "необычный" then
innertext = frame.args[1]
elseif mw.ustring.lower(frame.args[2]) == "редкий" then
innertext = frame.args[1]
elseif mw.ustring.lower(frame.args[2]) == "эпический" then
innertext = frame.args[1]
elseif mw.ustring.lower(frame.args[2]) == "легендарный" then
innertext = frame.args[1]
elseif mw.ustring.lower(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="vertical-align: text-bottom;">[[Файл:' .. r['icon'] .. '|20px|bottom|ссылка=' .. r['_pageName'] .. ']]</span>'
else
icon = '[[Файл:' .. r['icon'] .. '|20px|ссылка=' .. r['_pageName'] .. ']]'
end
local innertext = r['_pageName']
if mw.ustring.lower(frame.args[2]) == "quest" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "задача" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "обычный" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "необычный" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "редкий" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "эпический" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "легендарный" then
innertext = r['_pageName']
elseif mw.ustring.lower(frame.args[2]) == "мифический" then
innertext = r['_pageName']
elseif frame.args[2] ~= "" then
innertext = frame.args[2]
end
local item_quality = {}
if mw.ustring.lower(frame.args[2]) == "quest" then
item_quality = 'quest'
elseif mw.ustring.lower(frame.args[2]) == "задача" then
item_quality = 'quest'
elseif mw.ustring.lower(frame.args[2]) == "обычный" then
item_quality = 'common'
elseif mw.ustring.lower(frame.args[2]) == "необычный" then
item_quality = 'uncommon'
elseif mw.ustring.lower(frame.args[2]) == "редкий" then
item_quality = 'rare'
elseif mw.ustring.lower(frame.args[2]) == "эпический" then
item_quality = 'epic'
elseif mw.ustring.lower(frame.args[2]) == "легендарный" then
item_quality = 'legendary'
elseif mw.ustring.lower(frame.args[2]) == "мифический" then
item_quality = 'mythic'
else
item_quality = quality[mw.ustring.lower(r['quality'])]
end
text = icon .. ' <span class="itemname ' .. item_quality .. '">[[['.. r['_pageName'] .. '|<span class="ajaxttlink">' .. innertext ..'</span>]]]</span>'
end
return text
end
return p