Модуль:Prototypes/Механика/Стоимость: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 30: | Строка 30: | ||
for _, item in ipairs(priceData) do | for _, item in ipairs(priceData) do | ||
table.insert(output, '|-') | table.insert(output, '|-') | ||
table.insert(output, '! {{#invoke:Entity Lookup|createimagetooltip|Файл:' .. item.id .. '.png|' .. item.id .. '|Мета=32x32px,link=}} | table.insert(output, '! {{#invoke:Entity Lookup|createimagetooltip|Файл:' .. item.id .. '.png|' .. item.id .. '|Мета=32x32px,link=}}{{#invoke:Entity Lookup|getname|' .. item.id .. '}}') | ||
table.insert(output, '| {{ColorPalette|Other|price|' .. item.StaticPrice.price .. '}}$') | table.insert(output, '| {{ColorPalette|Other|price|' .. item.StaticPrice.price .. '}}$') | ||
end | end | ||
table.insert(output, '|}') | table.insert(output, '|}') | ||
return table.concat(output, "\n") | return frame:preprocess(table.concat(output, "\n")) | ||
end | end | ||
return p | return p | ||
Версия от 10:06, 23 марта 2025
Для документации этого модуля может быть создана страница Модуль:Prototypes/Механика/Стоимость/doc
-- Загрузка данных
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 = {}
table.insert(output, '{| class="wikitable"')
table.insert(output, '|-')
table.insert(output, '! Предмет')
table.insert(output, '! Стоимость')
for _, item in ipairs(priceData) do
table.insert(output, '|-')
table.insert(output, '! {{#invoke:Entity Lookup|createimagetooltip|Файл:' .. item.id .. '.png|' .. item.id .. '|Мета=32x32px,link=}}{{#invoke:Entity Lookup|getname|' .. item.id .. '}}')
table.insert(output, '| {{ColorPalette|Other|price|' .. item.StaticPrice.price .. '}}$')
end
table.insert(output, '|}')
return frame:preprocess(table.concat(output, "\n"))
end
return p