Файл:Imbox deletion.png Внимание! Начат процесс обновления Wiki до версии игры 10.x. Если у Вас есть желание принять участие, то Вы можете найти больше информации в нашем ECO Contribution Wiki Discord.

Редактирование: Модуль:GetRecipes

Материал из Eco - Русская Wiki
Перейти к:навигация, поиск

Сделанные вами изменения будут показаны читателям после того, как их утвердит уполномоченный участник (подробнее).

Внимание: Вы не вошли в систему. Ваш IP-адрес будет общедоступен, если вы запишете какие-либо изменения. Если вы войдёте или создадите учётную запись, её имя будет использоваться вместо IP-адреса, наряду с другими преимуществами.

Правка может быть отменена. Пожалуйста, просмотрите сравнение версий ниже, чтобы убедиться, что это нужная вам правка, и запишите страницу ниже, чтобы отменить правку.

Текущая версия Ваш текст
Строка 2: Строка 2:
local p = {}
local p = {}


local Utils = require('Module:Utils')
-- Grabs args from the parent frame
 
-- Trims and parses the args into a table, then returns the table
-- Main entry point for the Module
function norm()
function p.main(frame)
    local origArgs = mw.getCurrentFrame():getParent().args
  local test = ''
     local args = {}
 
      
  -- get args from the Template
     for k, v in pairs( origArgs ) do
  local args = Utils.normaliseArgs(frame)
        v = mw.text.trim( tostring( v ) )
 
        if v ~= '' then
  -- assign variables for item, table, and group
             args[k] = v
  local item = args.item
  local tag = args.tag
  local craftTable = args.table -- Don't override table
  local group = args.group
 
  -- load list of recipes
  local completeList = require("Module:CraftingRecipes")
  local recipeList = completeList.recipes
  local ingredientsList = completeList.ingredients
  local productsList = completeList.products
  local tableList = completeList.tables
 
  -- initialize a table to store recipes
  local recipes = {}
  local products = {}
  local ingredients = {}
 
  -- load CraftingParser
  local parser = require("Module:CraftingParser")
 
  -- priority: item > tag > table > group
  if item ~= nil then
     local itemProducts
 
    -- HACK Attempt to handle issue with tool recipes
    if productsList[item] and #productsList[item] == 1 and productsList[item][1] == '' then
      itemProducts = {item}
     elseif productsList[item] then
      itemProducts = productsList[item]
     end
 
    if itemProducts ~= nil then
      for _, itemProduct in pairs(itemProducts) do
        -- HACK: Skill books don't show us as a product of research pages, only the skill name.
        if string.sub(item, string.len(item) - 9) == 'Skill Book' then
            if (itemProduct ~= '' and recipeList[itemProduct .. ' Skill Book'] ~= nil) then
                table.insert(products, recipeList[itemProduct .. ' Skill Book'])
             end
        elseif (itemProduct ~= '' and recipeList[itemProduct] ~= nil) then
            table.insert(products, recipeList[itemProduct])
         end
         end
      end
     end
     end
   
    return args
end


     local itemIngredients
-- Main entry point for the Module
function p.main()
     local test = ''
-- get args from the Template
    local args = norm()
   
    -- assign variables for item, table, and group
    local item = args.item
    local table = args.table
    local group = args.group


     -- HACK Attempt to handle issue with tool recipes
     -- load list of recipes
     if ingredientsList[item] and #ingredientsList[item] == 1 and ingredientsList[item][1] == '' then
    local completeList = require( "Module:CraftingRecipes" )
      itemIngredients = {item}
    local recipeList = completeList.recipes
    elseif ingredientsList[item] then
    local ingredientsList = completeList.ingredients
      itemIngredients = ingredientsList[item]
local productsList = completeList.products
    end
    local tableList = completeList.tables
 
   
    if itemIngredients ~= nil then
    -- initialize a table to store recipes
      for _, itemIngredient in pairs(itemIngredients) do
    local recipes = {}
        if itemIngredient ~= '' then
local products = {}
          if recipeList[itemIngredient] ~= nil then
local ingredients = {}
            table.insert(ingredients, recipeList[itemIngredient])
   
          -- HACK: Skill books don't show us as a product of research pages, only the skill name.
    -- load CraftingParser
          elseif recipeList[itemIngredient .. ' Skill Book'] ~= nil then
    local parser = require( "Module:CraftingParser" )
            table.insert(ingredients, recipeList[itemIngredient .. ' Skill Book'])
          end
    -- priority: item > table > group
        end
     if item ~= nil then
      end
if productsList[item] ~= nil then
    end
local built = 1
    return parser.formattedItem(products, ingredients, item)
for num = 1, #productsList[item] do
 
if (productsList[item][num] ~= '' and recipeList[productsList[item][num]] ~= nil) then
  elseif tag ~= nil then
products[built] = recipeList[productsList[item][num]]
    itemIngredients = {}   
built = built + 1
     
end
    -- Tags do not appear in the 'products' list, so have to process manually
end
    for recipeName, recipe in pairs(recipeList) do
end
      local foundIngredient = false
      for _, variant in pairs(recipe.variants) do
if ingredientsList[item] ~= nil then
        for _, ingredient in pairs(variant.ingredients) do
local built = 1
          if ingredient[1] == 'TAG' and ingredient[2] == tag then
for num = 1, #ingredientsList[item] do
            foundIngredient = true
if (ingredientsList[item][num] ~= '' and recipeList[ingredientsList[item][num]] ~= nil) then
          end
ingredients[built] = recipeList[ingredientsList[item][num]]
built = built + 1
end
end
end
      return parser.formattedItem( products, ingredients, item )
       
    elseif table ~= nil then
        for num = 1, #tableList[table] do
            recipes[num] = recipeList[tableList[table][num]]
         end
         end
      end
      if foundIngredient then
        table.insert(itemIngredients, recipeName)
      end
    end


    if itemIngredients ~= nil then
         return parser.formattedTable( recipes, table )
      for _, itemIngredient in pairs(itemIngredients) do
         if itemIngredient ~= '' then
          if recipeList[itemIngredient] ~= nil then
    table.insert(ingredients, recipeList[itemIngredient])
          end
        end
      end
    end
    return parser.formattedItem(products, ingredients, tag)
   
  elseif craftTable ~= nil then


     for _, tbl in pairs(tableList[craftTable]) do
     else
      table.insert(recipes, recipeList[tbl])
        return 'Invalid use of parameters, please see [[Template:GetRecipes]].'
     end
     end
   
    return parser.formattedTable(recipes, craftTable)
   
  else
    return 'Invalid use of parameters, please see [[Template:GetRecipes]].'
  end
end
end


return p
return p
Обратите внимание, что все изменения в Eco - Русская Wiki рассматриваются как выпущенные на условиях лицензии CC BY-NC-SA 4.0 (см. Eco:Авторские права). Если вы не хотите, чтобы ваши тексты свободно распространялись и редактировались любым желающим, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений или скопировали их из источника в общественном достоянии или под совместимой лицензией. Не размещайте без разрешения материалы, защищённые авторским правом!

В целях защиты вики от автоматического спама мы просим вас решить следующую капчу:

Отменить Справка по редактированию (в новом окне)

Шаблон, используемый на этой странице: