Модуль:Prototypes/Хранилище/Предмет: различия между версиями

мНет описания правки
мНет описания правки
Строка 297: Строка 297:
     end
     end


     local foodSolution = item.SolutionContainerManager.solutions["food"]
     local function processSolution(solution)
    if not foodSolution or not foodSolution.reagents then
        local output = ""
         return ''
        if solution and solution.reagents then
            for _, reagent in ipairs(solution.reagents) do
                local chemInfo = chemTranslateData[reagent.ReagentId]
                local displayName = chemInfo and chemInfo.name or reagent.ReagentId
                output = output .. string.format(
                    '<li>[[Химия#chem_%s|%s]] (%d ед.)</li>',
                    reagent.ReagentId, displayName, reagent.Quantity
                )
            end
        end
         return output
     end
     end


     local result = ""
     local result = ""
     for _, reagent in ipairs(foodSolution.reagents) do
     result = result .. processSolution(item.SolutionContainerManager.solutions["food"])
        result = result .. string.format(
    result = result .. processSolution(item.SolutionContainerManager.solutions["beaker"])
            '<li>[[Химия#chem_%s|%s]] (%d ед.)</li>',
            reagent.ReagentId, reagent.ReagentId, reagent.Quantity
        )
    end


     return string.format('<ul class="1">%s</ul>', result)
     return result ~= "" and string.format('<ul class="1">%s</ul>', result) or ''
end
end