Модуль:Песочница/Pok: различия между версиями

Нет описания правки
мНет описания правки
Строка 1: Строка 1:
-- Загрузка данных
-- Загрузка данных
local itemData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/Item.json/data")
local itemData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/Item.json/data")
local itemSlotsData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemSlots.json/data")


local p = {}
local p = {}
Строка 30: Строка 31:
     end
     end
     return result
     return result
end
-- Функция для поиска первого startingItem в slots
local function getFirstStartingItem(data)
    if not data or not data.ItemSlots or not data.ItemSlots.slots then return nil end
   
    for _, slot in pairs(data.ItemSlots.slots) do
        if slot.startingItem then
            return slot.startingItem
        end
    end
   
    return nil
end
end


Строка 65: Строка 79:


     return string.format(
     return string.format(
         '{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Prototypes/Хранилище/Предмет|main|framing|contained|%s}} }}',
         '{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Prototypes/Хранилище/Предмет|main|framing|contained|%s}} {{#invoke:Prototypes/Хранилище/Предмет|main|slot|contained|%s}} }}',
         image, name, amount, prob, content.id
         image, name, amount, prob, content.id, content.id
     )
     )
end
end
Строка 298: Строка 312:
         elseif subMode == 'contained' then
         elseif subMode == 'contained' then
             return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}')
             return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}')
        elseif subMode == 'slot' then
        local itemDataEntry = findDataById(itemSlotsData, id)
        if not itemDataEntry then return "ID не найден в данных ItemSlots." end
        local startingItem = getFirstStartingItem(itemDataEntry)
        if not startingItem then return "Не найден startingItem в slots." end
        return frame:preprocess('{{СollapsibleMenu|' .. formatContent(startingItem)) .. '}}'
         else
         else
             return 'Неизвестный подрежим для framing: ' .. subMode
             return 'Неизвестный подрежим для framing: ' .. subMode
Строка 305: Строка 327:
     elseif mode == 'contained' then
     elseif mode == 'contained' then
         return frame:preprocess(getContainedOutput(itemDataIndex, id))
         return frame:preprocess(getContainedOutput(itemDataIndex, id))
    elseif mode == "slot" then
        local itemDataEntry = findDataById(itemSlotsData, id)
        if not itemDataEntry then return "ID не найден в данных ItemSlots." end
        local startingItem = getFirstStartingItem(itemDataEntry)
        if not startingItem then return "Не найден startingItem в slots." end
        return frame:preprocess(formatContent(startingItem))
     elseif mode == 'rolls' then
     elseif mode == 'rolls' then
         local entity = findDataById(itemDataIndex, id)
         local entity = findDataById(itemDataIndex, id)