Модуль:Entity Tags
Материал из Space Station 14 Вики
Для документации этого модуля может быть создана страница Модуль:Entity Tags/doc
local p = {}
local tagsData = mw.loadData("Модуль:IanComradeBot/prototypes/entity tags.json/data")
function p.main(frame)
local args = frame:getParent().args
local mode = args[1] or ""
local value = args[2] or ""
if mode == "id" then
for _, entry in ipairs(tagsData) do
if entry.id == value then
if entry.Tag and type(entry.Tag.tags) == "table" then
return table.concat(entry.Tag.tags, ", ")
end
end
end
return ""
elseif mode == "tag" then
local matchingIDs = {}
for _, entry in ipairs(tagsData) do
if entry.Tag and type(entry.Tag.tags) == "table" then
for _, tag in ipairs(entry.Tag.tags) do
if tag == value then
table.insert(matchingIDs, entry.id)
break
end
end
end
end
return table.concat(matchingIDs, ", ")
else
return "Неверный режим. Используйте 'id' или 'tag'."
end
end
return p