Модуль:Prototypes/Механика/Стоимость: различия между версиями

мНет описания правки
мНет описания правки
Строка 22: Строка 22:
function p.table(frame)
function p.table(frame)
     local output = {}
     local output = {}
    local seen = {}
     for _, item in ipairs(priceData) do
     for _, item in ipairs(priceData) do
         if tonumber(item.StaticPrice.price) ~= 0 then
         local numericPrice = tonumber(item.StaticPrice.price)
        if numericPrice and numericPrice ~= 0 then
             local name = frame:preprocess('{{#invoke:Entity Lookup|getname|' .. item.id .. '}}')
             local name = frame:preprocess('{{#invoke:Entity Lookup|getname|' .. item.id .. '}}')
             local price = frame:preprocess("{{ColorPalette|Other|price|" .. item.StaticPrice.price .. "}}$")
             local priceFormatted = frame:preprocess("{{ColorPalette|Other|price|" .. item.StaticPrice.price .. "}}$")
             table.insert(output, '|data-sort-value=' .. item.StaticPrice.price .. '|{{Cut-Layout|1=[[File:' .. item.id .. '.png|32px]] ' .. name .. '|2=' .. price .. '}}')
              
            table.insert(output, '|-')
            local key = name .. "-" .. priceFormatted
            if not seen[key] then
                seen[key] = true
                table.insert(output, '|data-sort-value=' .. item.StaticPrice.price .. '|{{Cut-Layout|1=[[File:' .. item.id .. '.png|32px|link=]] ' .. name .. '|2=' .. priceFormatted .. '}}')
                table.insert(output, '|-')
            end
         end
         end
     end
     end
     return frame:preprocess(table.concat(output, "\n"))
     return frame:preprocess(table.concat(output, "\n"))
end
end


return p
return p