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

Нет описания правки
Нет описания правки
Строка 284: Строка 284:
getChemOutput = function(itemData, id)
getChemOutput = function(itemData, id)
     local item = findDataById(itemData, id)
     local item = findDataById(itemData, id)
     if not item or not item.SolutionContainerManager or not item.SolutionContainerManager.solutions then return '' end
     if not item  
      or not item.SolutionContainerManager  
      or not item.SolutionContainerManager.solutions then  
        return ''
    end
 
    local foodSolution = item.SolutionContainerManager.solutions["food"]
    if not foodSolution or not foodSolution.reagents then
        return ''
    end


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