Модуль: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 minTemp = recipe.minTemp or recipe.min_temp or recipe.minTemperature
     local tempString = ""
    local maxTemp = recipe.maxTemp or recipe.max_temp or recipe.maxTemperature
      
      
     if minTemp then
     -- Проверяем наличие минимальной температуры
        local minValue = tonumber(minTemp)
    local hasMin = recipe.minTemp and recipe.minTemp ~= 0
        if minValue then
    -- Проверяем наличие максимальной температуры (если есть поле maxTemp)
            if maxTemp then
    local hasMax = recipe.maxTemp and recipe.maxTemp ~= 0
                local maxValue = tonumber(maxTemp)
   
                if maxValue and maxValue ~= 9999 and maxValue ~= 99999 then
    if hasMin and hasMax then
                    return string.format("от %до %", minValue, maxValue)
        tempString = string.format("от %до %", recipe.minTemp, recipe.maxTemp)
                else
    elseif hasMin then
                    return string.format("выше %", minValue)
        tempString = string.format("выше %", recipe.minTemp)
                end
    elseif hasMax then
            else
        tempString = string.format("ниже %", recipe.maxTemp)
                return string.format("выше %", minValue)
    else
            end
         tempString = "Нет данных"
        else
            return minTemp
         end
     end
     end
      
      
     return "Нет данных"
     return tempString
end
end
   
   
Строка 249: Строка 246:
             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