Crossout Вики
Регистрация
Crossout Вики
3622
страницы
Нет описания правки
Метка: sourceedit
Нет описания правки
(не показано 29 промежуточных версий 2 участников)
Строка 4: Строка 4:
 
function p.getStat(f)
 
function p.getStat(f)
 
 
 
AllStats = ""
Item=tostring(f.args[1])
 
param=tostring(f.args[2])
 
-- Item="Партизан"
 
-- param="Тип"
 
StatValue=""
 
 
local cabins = mw.loadData( 'Module:Stats/cabins' )
 
local cores = mw.loadData( 'Module:Stats/cores' )
 
local decorum = mw.loadData( 'Module:Stats/decorum' )
 
local melee = mw.loadData( 'Module:Stats/melee' )
 
local structure = mw.loadData( 'Module:Stats/structure' )
 
local summons = mw.loadData( 'Module:Stats/summons' )
 
local weapons = mw.loadData( 'Module:Stats/weapons' )
 
local wheels = mw.loadData( 'Module:Stats/wheels' )
 
   
if cabins[Item] ~= nil then
+
for i = 2, 100 do
if cabins[Item][param] ~= nil then
+
if f.args[i]==nil or f.args[i]=="" then
StatValue=cabins[Item][param]
+
break
else
 
StatValue="Не найдет такой параметр"
 
end
 
elseif cores[Item] ~= nil then
 
if cores[Item][param] ~= nil then
 
StatValue=cores[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
 
end
 
end
  +
elseif decorum[Item] ~= nil then
 
  +
if decorum[Item][param] ~= nil then
 
StatValue=decorum[Item][param]
+
Item =tostring(f.args[1])
 
param =tostring(f.args[i])
 
-- Item="Партизан"
 
-- param="Тип"
  +
if param=="Редкость" then
  +
rarity=getStatForParam(Item, "Редкость")
  +
StatValue = getRarity(rarity, rarity)
  +
elseif param=="РедкостьСтрокой" then
  +
StatValue = getStatForParam(Item, "Редкость");
 
else
 
else
StatValue="Не найдет такой параметр"
+
StatValue = getStatForParam(Item, param)
end
+
end
elseif melee[Item] ~= nil then
+
if melee[Item][param] ~= nil then
+
if i==2 then
StatValue=melee[Item][param]
+
AllStats = StatValue
 
else
 
else
  +
AllStats = AllStats.."||"..StatValue
StatValue="Не найдет такой параметр"
 
end
+
end
elseif structure[Item] ~= nil then
+
end
if structure[Item][param] ~= nil then
 
StatValue=structure[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
 
elseif summons[Item] ~= nil then
 
if summons[Item][param] ~= nil then
 
StatValue=summons[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
 
elseif weapons[Item] ~= nil then
 
if weapons[Item][param] ~= nil then
 
StatValue=weapons[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
 
elseif wheels[Item] ~= nil then
 
if wheels[Item][param] ~= nil then
 
StatValue=wheels[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
 
else
 
StatValue="Не найдет предмет с таким названием"
 
end
 
   
return StatValue
+
return AllStats
   
 
end
 
end
   
function p.getParam(f)
+
function getStatForParam(Item, param)
  +
return (#f.args)
 
 
local cabins = mw.loadData( 'Module:Stats/cabins' )
end
 
 
local cores = mw.loadData( 'Module:Stats/cores' )
 
local decorum = mw.loadData( 'Module:Stats/decorum' )
 
local melee = mw.loadData( 'Module:Stats/melee' )
 
local structure = mw.loadData( 'Module:Stats/structure' )
 
local summons = mw.loadData( 'Module:Stats/summons' )
 
local weapons = mw.loadData( 'Module:Stats/weapons' )
 
local wheels = mw.loadData( 'Module:Stats/wheels' )
  +
local quest = mw.loadData( 'Module:Stats/quest' )
 
  +
if param=="Ссылка" then
  +
Image=getStatForParam(Item, "Иконка")
  +
  +
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 cores[Item] ~= nil then
 
if cores[Item][param] ~= nil then
 
StatValue=cores[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
 
elseif decorum[Item] ~= nil then
 
if decorum[Item][param] ~= nil then
  +
StatValue=decorum[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
  +
elseif melee[Item] ~= nil then
  +
if melee[Item][param] ~= nil then
  +
StatValue=melee[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
 
end
  +
elseif structure[Item] ~= nil then
 
if structure[Item][param] ~= nil then
 
StatValue=structure[Item][param]
 
else
 
StatValue="Не найдет такой параметр"
  +
end
 
elseif summons[Item] ~= nil then
 
if summons[Item][param] ~= nil then
 
StatValue=summons[Item][param]
  +
else
 
StatValue="Не найдет такой параметр"
  +
end
 
elseif weapons[Item] ~= nil then
 
if weapons[Item][param] ~= nil then
 
StatValue=weapons[Item][param]
  +
else
 
StatValue="Не найдет такой параметр"
  +
end
 
elseif wheels[Item] ~= nil then
 
if wheels[Item][param] ~= nil then
 
StatValue=wheels[Item][param]
  +
else
  +
StatValue="Не найдет такой параметр"
  +
end
  +
elseif quest[Item] ~= nil then
  +
if quest[Item][param] ~= nil then
  +
StatValue=quest[Item][param]
  +
else
  +
StatValue="Не найдет такой параметр"
  +
end
 
else
 
StatValue="Не найдет предмет с таким названием"
 
end
  +
  +
return StatValue
 
end
  +
  +
function getRarity(rarity, text)
  +
  +
TextRar=""
  +
  +
if rarity=="Базовая" then
  +
TextRar= "<span class=\"RarityStart\" style=\"color:grey;\">"..text.."</span>"
  +
elseif rarity=="Обычная" then
  +
TextRar= "<span class=\"RarityW\" style=\"color:white;\">"..text.."</span>"
  +
elseif rarity=="Редкая" then
  +
TextRar= "<span class=\"RarityB\" style=\"color:#0066cc;\">"..text.."</span>"
  +
elseif rarity=="Особая" then
  +
TextRar= "<span class=\"RarityA\" style=\"color:#4acbc7;\">"..text.."</span>"
  +
elseif rarity=="Эпическая" then
  +
TextRar= "<span class=\"RarityP\" style=\"color:#b900ff;\">"..text.."</span>"
  +
elseif rarity=="Легендарная" then
  +
TextRar= "<span class=\"RarityL\" style=\"color:#fea040;\">"..text.."</span>"
  +
elseif rarity=="Реликтовая" then
  +
TextRar= "<span class=\"RarityO\" style=\"color:#ff6701;\">"..text.."</span>"
 
else
  +
TextRar=text
 
end
  +
 
return TextRar
  +
end
   
 
return p
 
return p

Версия от 06:26, 31 января 2020

Для документации этого модуля может быть создана страница Модуль: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) 
        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 cores     = mw.loadData( 'Module:Stats/cores' )
        local decorum   = mw.loadData( 'Module:Stats/decorum' )
        local melee     = mw.loadData( 'Module:Stats/melee' )
        local structure = mw.loadData( 'Module:Stats/structure' )
        local summons   = mw.loadData( 'Module:Stats/summons' )
        local weapons   = mw.loadData( 'Module:Stats/weapons' )
        local wheels    = mw.loadData( 'Module:Stats/wheels' )
        local quest    = mw.loadData( 'Module:Stats/quest' )
    
        if param=="Ссылка" then
            Image=getStatForParam(Item, "Иконка")

            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 cores[Item] ~= nil then
            if cores[Item][param] ~= nil then
                StatValue=cores[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end    
        elseif decorum[Item] ~= nil then
            if decorum[Item][param] ~= nil then
                StatValue=decorum[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end    
        elseif melee[Item] ~= nil then
            if melee[Item][param] ~= nil then
                StatValue=melee[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end    
        elseif structure[Item] ~= nil then
            if structure[Item][param] ~= nil then
                StatValue=structure[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end    
        elseif summons[Item] ~= nil then
            if summons[Item][param] ~= nil then
                StatValue=summons[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end    
        elseif weapons[Item] ~= nil then
            if weapons[Item][param] ~= nil then
                StatValue=weapons[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end    
        elseif wheels[Item] ~= nil then
            if wheels[Item][param] ~= nil then
                StatValue=wheels[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end
        elseif quest[Item] ~= nil then
            if quest[Item][param] ~= nil then
                StatValue=quest[Item][param] 
            else
                StatValue="Не найдет такой параметр"  
            end
        else
            StatValue="Не найдет предмет с таким названием"  
        end
        
        return StatValue        
end    

function getRarity(rarity, text)
    
    TextRar=""
    
    if rarity=="Базовая" then
        TextRar= "<span class=\"RarityStart\" style=\"color:grey;\">"..text.."</span>"
    elseif rarity=="Обычная" then
        TextRar= "<span class=\"RarityW\" style=\"color:white;\">"..text.."</span>"
    elseif rarity=="Редкая" then
        TextRar= "<span class=\"RarityB\" style=\"color:#0066cc;\">"..text.."</span>"
    elseif rarity=="Особая" then
        TextRar= "<span class=\"RarityA\" style=\"color:#4acbc7;\">"..text.."</span>"
    elseif rarity=="Эпическая" then
        TextRar= "<span class=\"RarityP\" style=\"color:#b900ff;\">"..text.."</span>"
    elseif rarity=="Легендарная" then
        TextRar= "<span class=\"RarityL\" style=\"color:#fea040;\">"..text.."</span>"
    elseif rarity=="Реликтовая" then
        TextRar= "<span class=\"RarityO\" style=\"color:#ff6701;\">"..text.."</span>"
    else
        TextRar=text
    end
    
    return TextRar
end    

return p