Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 1: | Строка 1: | ||
-- | -- Загрузка данных | ||
local | local accentData = mw.loadData("Модуль:IanComradeBot/prototypes/accent.json/data") | ||
local p = {} | local p = {} | ||
function p.table(frame) | function p.table(frame) | ||
local targetId = frame.args[1] or "" | |||
if targetId == "" then | |||
return "Ошибка: не указан параметр id." | |||
end | |||
local foundData = nil | |||
for _, item in ipairs(accentData) do | |||
if item.id == targetId then | |||
foundData = item | |||
break | |||
end | |||
end | |||
if not foundData then | |||
return "Ошибка: данные по id '" .. targetId .. "' не найдены." | |||
end | |||
local output = {} | local output = {} | ||
for | |||
for key, value in pairs(foundData.wordReplacements) do | |||
table.insert(output, string.format("| {{Cut-Layout|background-color=var(--bg-color-message-subtle)|%s|%s}}", key, value)) | |||
table.insert(output, "|-") | |||
end | end | ||
return | |||
return table.concat(output, "\n") | |||
end | end | ||
return p | return p | ||