Модуль:Prototypes/Объект/Торгомат: различия между версиями

мНет описания правки
мНет описания правки
Строка 32: Строка 32:
     local inventoryId = vendingMachine.pack
     local inventoryId = vendingMachine.pack
     local inventory = findDataById(inventories, inventoryId)
     local inventory = findDataById(inventories, inventoryId)
     if not inventory or not inventory.startingInventory then return "" end
     if not inventory then return "" end


     -- Формирование вывода  
     -- Формирование вывода  
     local result = "== Содержимое автомата ==\n"
     local result = "== Содержимое автомата ==\n"
     for itemId, count in pairs(inventory.startingInventory) do
 
         result = result .. "* " .. itemId .. " — " .. count .. "\n"
     -- Содержания автоматов основное
    if inventory.startingInventory then
        result = result .. "== Инвентарь ==\n"
        for itemId, count in pairs(inventory.startingInventory) do
            result = result .. "* " .. itemId .. " — " .. count .. "\n"
        end
    end
 
    -- Содержания автоматов после провода
    if inventory.contrabandInventory then
        result = result .. "== Провод ==\n"
        for itemId, count in pairs(inventory.contrabandInventory) do
            result = result .. "* " .. itemId .. " — " .. count .. "\n"
         end
    end
 
    -- Содержания автоматов после EMAG
    if inventory.emaggedInventory then
        result = result .. "== Эмаг ==\n"
        for itemId, count in pairs(inventory.emaggedInventory) do
            result = result .. "* " .. itemId .. " — " .. count .. "\n"
        end
     end
     end


Строка 71: Строка 92:
     -- Поиск автомата по ID
     -- Поиск автомата по ID
     local vendingMachine = findDataById(vendingMachines, id)
     local vendingMachine = findDataById(vendingMachines, id)
    if not vendingMachine or not vendingMachine.AccessReader then
        return "Нет данных о доступах"
    end
      
      
     -- Получение строки с доступами
     -- Получение доступа из данных автомата
     local access = vendingMachine.AccessReader.access
     local access = vendingMachine.AccessReader.access
    if not access then
        return "Нет данных о доступах"
    end
      
      
     -- Формирование строки для шаблона
     -- Формируем строку для вызова шаблона
     local templateCall = "{{#invoke:Prototypes/Механика/Доступ|parse|" .. access .. "}}"
     local templateCall = "{{#invoke:Prototypes/Механика/Доступ|parse|" .. access .. "}}"
      
      
     local result = mw.getCurrentFrame():preprocess(templateCall)
     -- Обрабатываем шаблон и возвращаем результат
   
    return mw.getCurrentFrame():preprocess(templateCall)
    return result
end
end