Модуль:tableofrecipes

Вернуться

Строка 102: Строка 102:
     return string.format("[[#%s|%s]]", ingredientId, ingredientName)
     return string.format("[[#%s|%s]]", ingredientId, ingredientName)
end
end
 
-- Форматирование температуры для отображения
local function formatTemperature(recipe)
local function formatTemperature(recipe)
     local tempString = ""
     local minTemp = recipe.minTemp or recipe.min_temp or recipe.minTemperature
    local maxTemp = recipe.maxTemp or recipe.max_temp or recipe.maxTemperature
      
      
     -- Проверяем наличие минимальной температуры
     if minTemp then
    local hasMin = recipe.minTemp and recipe.minTemp ~= 0
        local minValue = tonumber(minTemp)
    -- Проверяем наличие максимальной температуры (если есть поле maxTemp)
        if minValue then
    local hasMax = recipe.maxTemp and recipe.maxTemp ~= 0
            if maxTemp then
   
                local maxValue = tonumber(maxTemp)
    if hasMin and hasMax then
                if maxValue and maxValue ~= 9999 and maxValue ~= 99999 then
        tempString = string.format("от %до %", recipe.minTemp, recipe.maxTemp)
                    return string.format("от %до %", minValue, maxValue)
    elseif hasMin then
                else
        tempString = string.format("выше %", recipe.minTemp)
                    return string.format("выше %", minValue)
    elseif hasMax then
                end
        tempString = string.format("ниже %", recipe.maxTemp)
            else
    else
                return string.format("выше %", minValue)
         tempString = "Нет данных"
            end
        else
            return minTemp
         end
     end
     end
      
      
     return tempString
     return "Нет данных"
end
end
   
   
Строка 246: Строка 249:
             local result = resultData.name or "Нет результата"
             local result = resultData.name or "Нет результата"
             local resultImage = resultData.image or ""
             local resultImage = resultData.image or ""
           
             local minTemp = formatTemperature(recipe)
             local minTemp = formatTemperature(recipe)
   
   
             templateArgs.input = input .. " " .. inputImage
             templateArgs.input = input .. " " .. inputImage
             templateArgs.result = result .. " " .. resultImage
             templateArgs.result = result .. " " .. resultImage
             templateArgs.minTemp = minTemp  
             templateArgs.minTemp = minTemp
   
   
         -- Обработка для toolmadeRecipes
         -- Обработка для toolmadeRecipes