Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 61: | Строка 61: | ||
local componentDefs = load_module_data("component.json") | local componentDefs = load_module_data("component.json") | ||
local prototypeDefs = load_module_data("prototype.json") | local prototypeDefs = load_module_data("prototype.json") | ||
if not componentDefs or not prototypeDefs then | if not componentDefs or not prototypeDefs then | ||
return "" | return "" | ||
end | end | ||
local | local foundComponents = {} | ||
if | local foundPrototypes = {} | ||
-- If id directly matches a prototype or component key, include it | |||
if prototypeDefs[id] ~= nil then | |||
foundPrototypes[id] = true | |||
end | end | ||
if componentDefs[id] ~= nil then | |||
foundComponents[id] = true | |||
if | |||
end | end | ||
-- Support comma-separated list of ids (e.g. "absorbent,action") | |||
for name in string.gmatch(id, "[^,]+") do | |||
local n = trim(name) | |||
if n ~= "" then | |||
if prototypeDefs[n] ~= nil then foundPrototypes[n] = true end | |||
if componentDefs[n] ~= nil then foundComponents[n] = true end | |||
if | |||
end | end | ||
end | end | ||