Модуль:Песочница/Pok: различия между версиями

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


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


     local result = ""
     result = result .. processSolution(item.SolutionContainerManager.solutions["food"])
     for _, reagent in ipairs(foodSolution.reagents) do
     result = result .. processSolution(item.SolutionContainerManager.solutions["beaker"])
        result = result .. string.format(
            '<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