|
|
| (не показано 47 промежуточных версий этого же участника) |
| Строка 1: |
Строка 1: |
| -- Загрузка данных
| |
| local priceData = mw.loadData("Модуль:IanComradeBot/prototypes/StaticPrice.json/data")
| |
|
| |
|
| local p = {}
| |
|
| |
| function p.main(frame)
| |
| -- Получаем первый параметр, который должен быть id
| |
| local id = frame.args[1] or frame.args.id
| |
| if not id then
| |
| return "Ошибка: не передан id"
| |
| end
| |
|
| |
| -- Проходим по всем записям в priceData
| |
| for _, item in ipairs(priceData) do
| |
| if item.id == id then
| |
| return frame:preprocess("{{ColorPalette|Other|price|" .. item.StaticPrice.price .. "}}$")
| |
| end
| |
| end
| |
|
| |
| -- Если не нашли совпадение, возвращаем стандартный текст
| |
| return frame:preprocess("нет")
| |
| end
| |
|
| |
| function p.table(frame)
| |
| local output = {}
| |
| for _, item in ipairs(priceData) do
| |
| local name = frame:preprocess('{{#invoke:Entity Lookup|getname|' .. item.id .. '}}')
| |
| local price = frame:preprocess('{{ColorPalette|Other|price|' .. item.StaticPrice.price .. '}}') .. '$'
| |
| table.insert(output, '|-')
| |
| table.insert(output, '| {{Cut-Layout|' .. name .. '|' .. price .. '}}')
| |
| end
| |
| return frame:preprocess(table.concat(output, "\n"))
| |
| end
| |
|
| |
| return p
| |