Модуль:Prototypes/Роль/Лодаут: различия между версиями

Новая страница: «-- Загрузка local gearRoleLoadout = mw.loadData("Модуль:IanComradeBot/roleLoadout.json/data") local gearloadoutGroup = mw.loadData("Модуль:IanComradeBot/loadoutGroup.json/data") local gearloadout = mw.loadData("Модуль:IanComradeBot/loadout.json/data") local p = {} function p.main(searchKey, roleId) local results = {} local role = nil for _, r in ipairs(gearRoleLoadout) do if r.id == roleId then...»
 
мНет описания правки
Строка 1: Строка 1:
-- Загрузка
local p = {}
 
local gearRoleLoadout  = mw.loadData("Модуль:IanComradeBot/roleLoadout.json/data")
local gearRoleLoadout  = mw.loadData("Модуль:IanComradeBot/roleLoadout.json/data")
local gearloadoutGroup  = mw.loadData("Модуль:IanComradeBot/loadoutGroup.json/data")
local gearloadoutGroup  = mw.loadData("Модуль:IanComradeBot/loadoutGroup.json/data")
local gearloadout      = mw.loadData("Модуль:IanComradeBot/loadout.json/data")
local gearloadout      = mw.loadData("Модуль:IanComradeBot/loadout.json/data")


local p = {}
function p.getEquipment(searchKey, roleId)
 
if not roleId then
function p.main(searchKey, roleId)
return '<div class="role">Параметр roleId не указан</div>'
    local results = {}
end
 
local results = {}
    local role = nil
local role = nil
    for _, r in ipairs(gearRoleLoadout) do
for _, r in ipairs(gearRoleLoadout) do
        if r.id == roleId then
if r.id == roleId then
            role = r
role = r
            break
break
        end
end
    end
end
 
if not role then
    if not role then
return '<div class="role">Роль с id "' .. tostring(roleId) .. '" не найдена</div>'
        return '<div class="role">Роль с id "' .. roleId .. '" не найдена</div>'
end
    end
for _, groupId in ipairs(role.groups or {}) do
 
local group = nil
    for _, groupId in ipairs(role.groups or {}) do
for _, g in ipairs(gearloadoutGroup) do
        local group = nil
if g.id == groupId then
        for _, g in ipairs(gearloadoutGroup) do
group = g
            if g.id == groupId then
break
                group = g
end
                break
end
            end
if group then
        end
for _, loadoutId in ipairs(group.loadouts or {}) do
 
local loadout = nil
        if group then
for _, l in ipairs(gearloadout) do
            for _, loadoutId in ipairs(group.loadouts or {}) do
if l.id == loadoutId then
                local loadout = nil
loadout = l
                for _, l in ipairs(gearloadout) do
break
                    if l.id == loadoutId then
end
                        loadout = l
end
                        break
if loadout and loadout.equipment then
                    end
local eqValue = loadout.equipment[searchKey]
                end
if eqValue then
 
table.insert(results, eqValue)
                if loadout and loadout.equipment then
end
                    local eqValue = loadout.equipment[searchKey]
end
                    if eqValue then
end
                        table.insert(results, eqValue)
end
                    end
end
                end
local output = {}
            end
for _, eq in ipairs(results) do
        end
table.insert(output, '<div class="role">' .. eq .. '</div>')
    end
end
 
return table.concat(output, "\n")
    local output = {}
    for _, eq in ipairs(results) do
        table.insert(output, '<div class="test">' .. eq .. '</div>')
    end
 
    return table.concat(output, "\n")
end
end


return p
return p