Модуль:Prototypes/Механика/Исследование: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 5: | Строка 5: | ||
-- Загрузка данных из JSON | -- Загрузка данных из JSON | ||
local data = mw.text.jsonDecode(mw.title.new("Участник:IanComradeBot/entity_prototypes.json"):getContent()) | local data = mw.text.jsonDecode(mw.title.new("Участник:IanComradeBot/entity_prototypes.json"):getContent()) | ||
-- Поиск платы по ID и извлечение её названия | -- Поиск платы по ID и извлечение её названия | ||
| Строка 28: | Строка 20: | ||
local machineName = board.name:gsub(" %(машинная плата%)", ""):gsub(" %(консольная плата%)", "") | local machineName = board.name:gsub(" %(машинная плата%)", ""):gsub(" %(консольная плата%)", "") | ||
-- Поиск машины по | -- Список исключений | ||
local excludeWords = {"Unanchored", "Debug", "Admin"} | |||
-- Поиск машины по новому названию | |||
for _, entity in pairs(data) do | for _, entity in pairs(data) do | ||
if entity.name == machineName then | if entity.name == machineName then | ||
return entity.id -- Возвращаем ID машины | -- Проверка на наличие исключений в ID | ||
local shouldExclude = false | |||
for _, word in ipairs(excludeWords) do | |||
if entity.id:find(word) then | |||
shouldExclude = true | |||
break | |||
end | |||
end | |||
if not shouldExclude then | |||
return entity.id -- Возвращаем ID машины | |||
end | |||
end | end | ||
end | end | ||
| Строка 86: | Строка 92: | ||
-- Проверка каждого ID в recipeUnlocks | -- Проверка каждого ID в recipeUnlocks | ||
for _, recipe in ipairs(tech.recipeUnlocks) do | for _, recipe in ipairs(tech.recipeUnlocks) do | ||
local machineID = translateBoardIDToMachineID(recipe) -- Переводим только платы | local machineID = translateBoardIDToMachineID(recipe) or recipe -- Переводим только платы, остальные оставляем как есть | ||
out = out .. frame:preprocess('<li>{{#invoke:Entity Lookup|createimagetooltip|Файл:' .. machineID .. '.png|' .. machineID .. '|Мета=32x32px,link=}} {{#invoke:Entity Lookup|getname|' .. machineID .. '}}</li>') | |||
end | end | ||