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

мНет описания правки
мНет описания правки
Строка 20: Строка 20:


-- Получение инвентаря автомата
-- Получение инвентаря автомата
local function getInventoryOutput(id)
local function getInventoryOutput(id, mode)
     local vendingMachines = loadData("User:IanComradeBot/prototypes/vending machines.json")
     local vendingMachines = loadData("User:IanComradeBot/prototypes/vending machines.json")
     local inventories = loadData("User:IanComradeBot/prototypes/vending machines/inventories.json")
     local inventories = loadData("User:IanComradeBot/prototypes/vending machines/inventories.json")
Строка 35: Строка 35:
     if not inventory then return "" end
     if not inventory then return "" end


     -- Формирование вывода  
     -- Формирование вывода
     local result = "== Содержимое автомата ==\n"
     local result = "== Содержимое автомата ==\n"


     -- Содержания автоматов основное
     -- Основной инвентарь
     if inventory.startingInventory then
     if mode == "inventory" and inventory.startingInventory then
         result = result .. "== Инвентарь ==\n"
         result = result .. "== Инвентарь ==\n"
         for itemId, count in pairs(inventory.startingInventory) do
         for itemId, count in pairs(inventory.startingInventory) do
Строка 46: Строка 46:
     end
     end


     -- Содержания автоматов после провода
     -- Содержания после провода
     if inventory.contrabandInventory then
     if mode == "contraband" and inventory.contrabandInventory then
         result = result .. "== Провод ==\n"
         result = result .. "== Провод ==\n"
         for itemId, count in pairs(inventory.contrabandInventory) do
         for itemId, count in pairs(inventory.contrabandInventory) do
Строка 54: Строка 54:
     end
     end


     -- Содержания автоматов после EMAG
     -- Содержания после EMAG
     if inventory.emaggedInventory then
     if mode == "emag" and inventory.emaggedInventory then
         result = result .. "== Эмаг ==\n"
         result = result .. "== Эмаг ==\n"
         for itemId, count in pairs(inventory.emaggedInventory) do
         for itemId, count in pairs(inventory.emaggedInventory) do
Строка 111: Строка 111:
function p.main(frame)
function p.main(frame)
     local id = frame.args.id
     local id = frame.args.id
    local mode = frame.args.mode
     if not id then return "" end
     if not id then return "" end


     -- Определение действия на основе ID
     -- Определение действия на основе ID и выбранного режима
     if frame.args.mode == "inventory" then
     if mode == "inventory" or mode == "contraband" or mode == "emag" then
         return getInventoryOutput(id)
         return getInventoryOutput(id, mode)
     elseif frame.args.mode == "restock" then
     elseif mode == "restock" then
         return getRestockOutput(id)
         return getRestockOutput(id)
     elseif frame.args.mode == "access" then
     elseif mode == "access" then
         return getAccessOutput(id)
         return getAccessOutput(id)
     else
     else