Модуль:Prototypes/Объект/Торгомат: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 26: | Строка 26: | ||
-- Поиск автомата по ID | -- Поиск автомата по ID | ||
local vendingMachine = findDataById(vendingMachines, id) | local vendingMachine = findDataById(vendingMachines, id) | ||
if not vendingMachine then return "" end | if not vendingMachine then return "Автомат с таким ID не найден." 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 | ||
local inventory = findDataById(inventories, inventoryId) | local inventory = findDataById(inventories, inventoryId) | ||
if not inventory then return "" end | if not inventory then return "Данные об инвентаре отсутствуют." end | ||
-- Формирование вывода | -- Формирование вывода | ||
| Строка 42: | Строка 42: | ||
for itemId, count in pairs(inventory.startingInventory) do | for itemId, count in pairs(inventory.startingInventory) do | ||
result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|background-color=#d7d7ff0b|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|background-color=#d7d7ff0b|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | ||
end | |||
if result == "" then | |||
return "Основной инвентарь пуст." | |||
end | end | ||
-- Содержания после провода | -- Содержания после провода | ||
elseif mode == "contraband" | elseif mode == "contraband" then | ||
if inventory.contrabandInventory then | |||
for itemId, count in pairs(inventory.contrabandInventory) do | |||
result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|background-color=#d7d7ff0b|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | |||
end | |||
end | |||
if result == "" then | |||
return "Не имеет дополнительного ассортимента после перерезания провода." | |||
end | end | ||
-- Содержания после EMAG | -- Содержания после EMAG | ||
elseif mode == "emag" | elseif mode == "emag" then | ||
if inventory.emaggedInventory then | |||
for itemId, count in pairs(inventory.emaggedInventory) do | |||
result = result .. mw.getCurrentFrame():preprocess("{{LinkСard|SideStyle=1|background-color=#d7d7ff0b|image=" .. itemId .. ".png|name={{#invoke:Entity Lookup|getname|" .. itemId .. "}} [" .. count .. "]}}") | |||
end | |||
end | |||
if result == "" then | |||
return "Не имеет дополнительного ассортимента после взлома криптографическим секвенсором." | |||
end | end | ||
end | end | ||
| Строка 71: | Строка 84: | ||
-- Получение ID пополнителя | -- Получение ID пополнителя | ||
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 | |||
for _, restock in ipairs(restockData) do | for _, restock in ipairs(restockData) do | ||
if restock.canRestock and table.concat(restock.canRestock):find(packId) then | if restock.canRestock and table.concat(restock.canRestock):find(packId) then | ||
return mw.getCurrentFrame():preprocess("{{LinkСard|background-color=#d7d7ff0b|image=" .. restock.id .. " | return mw.getCurrentFrame():preprocess("{{LinkСard|background-color=#d7d7ff0b|image=" .. restock.id .. "|name={{#invoke:Entity Lookup|getname|" .. restock.id .. "}}|link=Торговые автоматы#{{#invoke:Entity Lookup|getname|" .. restock.id .. "}}}}") | ||
end | end | ||
end | end | ||
| Строка 93: | Строка 109: | ||
if not access then | if not access then | ||
return "Доступ не требуется" | return "Доступ не требуется." | ||
end | end | ||