Для документации этого модуля может быть создана страница Модуль:GetStat/doc
local p = {}
function p.getStat(f)
AllStats = ""
for i = 2, 100 do
if f.args[i]==nil or f.args[i]=="" then
break
end
Item =tostring(f.args[1])
param =tostring(f.args[i])
-- Item="Партизан"
-- param="Тип"
if param=="Редкость" then
--rarity=getStatForParam(Item, "Редкость")
--StatValue = getRarity(rarity, rarity)
StatValue = getStatForParam(Item, param)
elseif param=="РедкостьСтрокой" then
StatValue = getStatForParam(Item, "Редкость");
else
StatValue = getStatForParam(Item, param)
end
if i==2 then
AllStats = StatValue
else
AllStats = AllStats.."||"..StatValue
end
end
return AllStats
end
function getStatForParam(Item, param)
local cabins = mw.loadData( 'Module:Stats/cabins' )
local weapons = mw.loadData( 'Module:Stats/weapons' )
local cores = mw.loadData( 'Module:Stats/cores' )
local wheels = mw.loadData( 'Module:Stats/wheels' )
local structure = mw.loadData( 'Module:Stats/structure' )
local building = mw.loadData( 'Module:Stats/building' )
local stripes = mw.loadData( 'Module:Stats/stripes' )
local other = mw.loadData( 'Module:Stats/other' )
local quest = mw.loadData( 'Module:Stats/quest' )
if param=="Ссылка" then
--Image=getStatForParam(Item, "Иконка")
Image=Item..".png"
StatValue = "[[Файл:"..Image.."|30x30px|link="..Item.."]][["..Item.."|<span class=\"ajaxttlink\">"..getRarity(getStatForParam(Item, "Редкость"), Item).."</span>]]"
return StatValue
end
if cabins[Item] ~= nil then
if cabins[Item][param] ~= nil then
StatValue=cabins[Item][param]
else
StatValue="НЕТ"
end
elseif weapons[Item] ~= nil then
if weapons[Item][param] ~= nil then
StatValue=weapons[Item][param]
else
StatValue="НЕТ"
end
elseif cores[Item] ~= nil then
if cores[Item][param] ~= nil then
StatValue=cores[Item][param]
else
StatValue="НЕТ"
end
elseif wheels[Item] ~= nil then
if wheels[Item][param] ~= nil then
StatValue=wheels[Item][param]
else
StatValue="НЕТ"
end
elseif structure[Item] ~= nil then
if structure[Item][param] ~= nil then
StatValue=structure[Item][param]
else
StatValue="НЕТ"
end
elseif building[Item] ~= nil then
if building[Item][param] ~= nil then
StatValue=building[Item][param]
else
StatValue="НЕТ"
end
elseif stripes[Item] ~= nil then
if stripes[Item][param] ~= nil then
StatValue=stripes[Item][param]
else
StatValue="НЕТ"
end
elseif other[Item] ~= nil then
if other[Item][param] ~= nil then
StatValue=other[Item][param]
else
StatValue="НЕТ"
end
elseif quest[Item] ~= nil then
if quest[Item][param] ~= nil then
StatValue=quest[Item][param]
--if not IsEmpty(StatValue) then
--StatValue="+++"
--else
--StatValue=quest[Item][param]
--end
else
StatValue="НЕТ"
end
else
StatValue="НЕТ"
end
fix = mw.loadData( 'Module:Stats/fix' )
if fix[Item] ~= nil then
if fix[Item][param] ~= nil then
StatValueFix=fix[Item][param]
StatValue=StatValueFix
else
StatValueFix=""
end
else
StatValueFix=""
end
return StatValue
end
function getRarity(rarity, text)
text=string.gsub(text, "_", " ");
TextRar=""
if rarity=="Базовая" then
TextRar= "<span class=\"RarityStart\" >"..text.."</span>"
elseif rarity=="Обычная" then
TextRar= "<span class=\"RarityW\" >"..text.."</span>"
elseif rarity=="Редкая" then
TextRar= "<span class=\"RarityB\" >"..text.."</span>"
elseif rarity=="Особая" then
TextRar= "<span class=\"RarityA\" >"..text.."</span>"
elseif rarity=="Эпическая" then
TextRar= "<span class=\"RarityP\" >"..text.."</span>"
elseif rarity=="Легендарная" then
TextRar= "<span class=\"RarityL\" >"..text.."</span>"
elseif rarity=="Реликтовая" then
TextRar= "<span class=\"RarityO\" >"..text.."</span>"
else
TextRar=text
end
return TextRar
end
--function IsEmpty(t)
-- if not t then
-- return true
-- end
-- for _, _ in pairs(t) do
-- return false
-- end
-- return true
--end
return p