Модуль:Prototypes/Объект/Торгомат: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 23: | Строка 23: | ||
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") | ||
local vendingMachine = findDataById(vendingMachines, id) | local vendingMachine = findDataById(vendingMachines, id) | ||
if not vendingMachine then return "" end | if not vendingMachine then return "" end | ||
local inventoryId = vendingMachine.VendingMachine and vendingMachine.VendingMachine.pack | local inventoryId = vendingMachine.VendingMachine and vendingMachine.VendingMachine.pack | ||
if not inventoryId then return "" end | if not inventoryId then return "" end | ||
| Строка 35: | Строка 32: | ||
if not inventory then return "" end | if not inventory then return "" end | ||
local result = "" | local result = "" | ||
-- Основной инвентарь | -- Основной инвентарь | ||
if mode == "inventory" and inventory.startingInventory then | if mode == "inventory" and inventory.startingInventory then | ||
| Строка 43: | Строка 38: | ||
result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | ||
end | end | ||
-- Содержания после провода | -- Содержания после провода | ||
elseif mode == "contraband" and inventory.contrabandInventory then | |||
for itemId, count in pairs(inventory.contrabandInventory) do | for itemId, count in pairs(inventory.contrabandInventory) do | ||
result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | ||
end | end | ||
-- Содержания после EMAG | -- Содержания после EMAG | ||
elseif mode == "emag" and inventory.emaggedInventory then | |||
for itemId, count in pairs(inventory.emaggedInventory) do | for itemId, count in pairs(inventory.emaggedInventory) do | ||
result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | ||
end | end | ||
end | end | ||
return result | return result | ||
end | end | ||
| Строка 66: | Строка 56: | ||
local vendingMachines = loadData("User:IanComradeBot/prototypes/vending machines.json") | local vendingMachines = loadData("User:IanComradeBot/prototypes/vending machines.json") | ||
local restockData = loadData("User:IanComradeBot/prototypes/vending machines/restock.json") | local restockData = loadData("User:IanComradeBot/prototypes/vending machines/restock.json") | ||
local vendingMachine = findDataById(vendingMachines, id) | local vendingMachine = findDataById(vendingMachines, id) | ||
if not vendingMachine then return "" end | if not vendingMachine then return "" end | ||
local packId = vendingMachine.VendingMachine and vendingMachine.VendingMachine.pack | local packId = vendingMachine.VendingMachine and vendingMachine.VendingMachine.pack | ||
if not packId then return "" end | if not packId then return "" end | ||
| Строка 87: | Строка 74: | ||
local function getAccessOutput(id) | local function getAccessOutput(id) | ||
local vendingMachines = loadData("User:IanComradeBot/prototypes/vending machines.json") | local vendingMachines = loadData("User:IanComradeBot/prototypes/vending machines.json") | ||
local vendingMachine = findDataById(vendingMachines, id) | local vendingMachine = findDataById(vendingMachines, id) | ||
local access = vendingMachine.AccessReader and vendingMachine.AccessReader.access | local access = vendingMachine.AccessReader and vendingMachine.AccessReader.access | ||
| Строка 98: | Строка 81: | ||
end | end | ||
local templateCall = "{{#invoke:Prototypes/Механика/Доступ|parse|" .. access .. "}}" | local templateCall = "{{#invoke:Prototypes/Механика/Доступ|parse|" .. access .. "}}" | ||
return mw.getCurrentFrame():preprocess(templateCall) | return mw.getCurrentFrame():preprocess(templateCall) | ||
end | end | ||
| Строка 112: | Строка 92: | ||
if not id then return "" end | if not id then return "" end | ||
if mode == "inventory" or mode == "contraband" or mode == "emag" then | if mode == "inventory" or mode == "contraband" or mode == "emag" then | ||
return getInventoryOutput(id, mode) | return getInventoryOutput(id, mode) | ||