Модуль:GetField: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 447: | Строка 447: | ||
local result = table.concat(out, " ") | local result = table.concat(out, " ") | ||
return preprocess_or_return(frame, result) | return preprocess_or_return(frame, result) | ||
end | |||
function p.getGenerator(frame) | |||
local args = frame.args or {} | |||
local searchId = args[1] or "" | |||
local kind = (args[2] or ""):lower() | |||
local generatorId = args[3] or "" | |||
if searchId == "" or generatorId == "" then | |||
return "" | |||
end | |||
if kind ~= "prototype" and kind ~= "component" then | |||
return "" | |||
end | |||
local idsJson = p.findInGenerator({ args = { searchId, kind, generatorId } }) | |||
local ok, ids = pcall(mw.text.jsonDecode, idsJson or "") | |||
if not ok or type(ids) ~= "table" or #ids == 0 then | |||
return "" | |||
end | |||
local okOut, outJson = pcall(mw.text.jsonEncode, ids) | |||
if okOut and outJson then | |||
return outJson | |||
end | |||
return "" | |||
end | end | ||