Модуль:RecipeUtils: различия между версиями

Материал из Eco - Русская Wiki
Перейти к:навигация, поиск
[досмотренная версия][досмотренная версия]
Нет описания правки
Нет описания правки
Строка 9: Строка 9:
         for ProductName,ProductData in pairs(RecipeData.Products) do
         for ProductName,ProductData in pairs(RecipeData.Products) do
             if ProductName == ItemName and ProductData.Type == "ITEM" then
             if ProductName == ItemName and ProductData.Type == "ITEM" then
                 if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. ", " .. RecipeName end
                 if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. "," .. RecipeName end
             end
             end
         end
         end
Строка 22: Строка 22:
         for IngredientName,IngredientData in pairs(RecipeData.Ingredients) do
         for IngredientName,IngredientData in pairs(RecipeData.Ingredients) do
             if IngredientName == TagName and IngredientData.Type == "TAG" then
             if IngredientName == TagName and IngredientData.Type == "TAG" then
                 if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. ", " .. RecipeName end
                 if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. "," .. RecipeName end
             end
             end
         end
         end
Строка 34: Строка 34:
         for IngredientName,IngredientData in pairs(RecipeData.Ingredients) do
         for IngredientName,IngredientData in pairs(RecipeData.Ingredients) do
             if IngredientName == ItemName and IngredientData.Type == "ITEM" then
             if IngredientName == ItemName and IngredientData.Type == "ITEM" then
                 if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. ", " .. RecipeName end
                 if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. "," .. RecipeName end
             end
             end
         end
         end
Строка 46: Строка 46:
     if (RecipeList ~= "") then
     if (RecipeList ~= "") then
         CraftTable = CraftTable .. "<table><tr><th>Test</th></tr>";
         CraftTable = CraftTable .. "<table><tr><th>Test</th></tr>";
         for Count, RecipeName in pairs(RecipeList) do
         for List in string.gmatch(RecipeList, "([^,]+)") do
              
              
         end
         end
          CraftTable = CraftTable .. "</table>";
        CraftTable = CraftTable .. "</table>";
     end
     end
     return CraftTable
     return CraftTable

Версия от 05:29, 19 августа 2025

Для документации этого модуля может быть создана страница Модуль:RecipeUtils/doc

local Utils = require('Module:Utils')
local RecipesData = require('Module:RecipeData')
local ItemsData = require('Module:ItemData')
local p = {}

function p.ItemCraft(ItemName)
    local Recipes = ""
    for RecipeName,RecipeData in pairs(RecipesData.recipes) do
        for ProductName,ProductData in pairs(RecipeData.Products) do
            if ProductName == ItemName and ProductData.Type == "ITEM" then
                if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. "," .. RecipeName end
            end
        end
    end
           
    return Recipes
end

function p.TagIngredient(TagName)
    local Recipes = ""
    for RecipeName,RecipeData in pairs(RecipesData.recipes) do
        for IngredientName,IngredientData in pairs(RecipeData.Ingredients) do
            if IngredientName == TagName and IngredientData.Type == "TAG" then
                if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. "," .. RecipeName end
            end
        end
    end
    return Recipes
end

function p.ItemIngredient(ItemName)
    local Recipes = ""
    for RecipeName,RecipeData in pairs(RecipesData.recipes) do
        for IngredientName,IngredientData in pairs(RecipeData.Ingredients) do
            if IngredientName == ItemName and IngredientData.Type == "ITEM" then
                if (Recipes == "") then Recipes = Recipes .. RecipeName else Recipes = Recipes .. "," .. RecipeName end
            end
        end
    end
    return Recipes
end

function p.CraftTable(RecipeList)
    local CraftTable = ""

    if (RecipeList ~= "") then
        CraftTable = CraftTable .. "<table><tr><th>Test</th></tr>";
        for List in string.gmatch(RecipeList, "([^,]+)") do
            
        end
        CraftTable = CraftTable .. "</table>";
    end
    return CraftTable
end

return p