Bearbeiten von „Modul:GetRecipes

Aus Eco - Deutsches Wiki
Wechseln zu:Navigation, Suche

Deine Änderungen werden angezeigt, sobald ein dazu berechtigter Benutzer sie akzeptiert hat. (Hilfe)

Warnung: Du bist nicht angemeldet. Deine IP-Adresse wird bei Bearbeitungen öffentlich sichtbar. Melde dich an oder erstelle ein Benutzerkonto, damit Bearbeitungen deinem Benutzernamen zugeordnet werden. Ein eigenes Benutzerkonto hat eine ganze Reihe von Vorteilen.

Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.

Aktuelle Version Dein Text
Zeile 1: Zeile 1:
-- Module:GetRecipes (https://wiki.play.eco/en/Module:GetRecipes)
local p = {}
local p = {}


local Utils = require('Module:Utils')


-- Main entry point for the Module
-- Grabs args from the parent frame
function p.main(frame)
-- Trims and parses the args into a table, then returns the table
  local test = ''
function norm()
 
    local origArgs = mw.getCurrentFrame():getParent().args
  -- get args from the Template
     local args = {}
  local args = Utils.normaliseArgs(frame)
      
 
     for k, v in pairs( origArgs ) do
  -- assign variables for item, table, and group
        v = mw.text.trim( tostring( v ) )
  local item = args.item
        if v ~= '' then
  local tag = args.tag
             args[k] = v
  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


     -- HACK Attempt to handle issue with tool recipes
-- Main entry point for the Module
     if ingredientsList[item] and #ingredientsList[item] == 1 and ingredientsList[item][1] == '' then
function p.main()
      itemIngredients = {item}
     -- get args from the Template
     elseif ingredientsList[item] then
    local args = norm()
      itemIngredients = ingredientsList[item]
   
    end
     -- assign variables for item, table, and group
    local item = args.item
    local table = args.table
     local group = args.group


     if itemIngredients ~= nil then
     -- load list of recipes
      for _, itemIngredient in pairs(itemIngredients) do
    local completeList = require( "Module:CraftingRecipes" )
        if itemIngredient ~= '' then
    local recipeList = completeList.recipes
          if recipeList[itemIngredient] ~= nil then
    local itemList = completeList.items
            table.insert(ingredients, recipeList[itemIngredient])
    local tableList = completeList.tables
          -- HACK: Skill books don't show us as a product of research pages, only the skill name.
   
          elseif recipeList[itemIngredient .. ' Skill Book'] ~= nil then
    -- groups no longer exists. Need to check all dependencies on this throughout other modules. Expecting implication to be removal of 'used in' table in the wiki.
            table.insert(ingredients, recipeList[itemIngredient .. ' Skill Book'])
    --local groupList = completeList.groups
          end
   
        end
    -- initialize a table to store recipes
      end
    local recipes = {}
     end
   
     return parser.formattedItem(products, ingredients, item)
     -- load CraftingParser
     local parser = require( "Module:CraftingParser" )


  elseif tag ~= nil then
      -- priority: item > table > group
    itemIngredients = {}   
    if item ~= nil then
     
if productsList[item] ~= nil then
    -- Tags do not appear in the 'products' list, so have to process manually
local built = 1
    for recipeName, recipe in pairs(recipeList) do
for num = 1, #productsList[item] do
      local foundIngredient = false
if (productsList[item][num] ~= '' and recipeList[productsList[item][num]] ~= nil) then
      for _, variant in pairs(recipe.variants) do
products[built] = recipeList[productsList[item][num]]
        for _, ingredient in pairs(variant.ingredients) do
built = built + 1
          if ingredient[1] == 'TAG' and ingredient[2] == tag then
end
            foundIngredient = true
end
          end
end
if ingredientsList[item] ~= nil then
local built = 1
for num = 1, #ingredientsList[item] do
if (ingredientsList[item][num] ~= '' and recipeList[ingredientsList[item][num]] ~= nil) then
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
Bitte kopiere keine Webseiten, die nicht deine eigenen sind, benutze keine urheberrechtlich geschützten Werke ohne Erlaubnis des Urhebers!
Du gibst uns hiermit deine Zusage, dass du den Text selbst verfasst hast, dass der Text Allgemeingut (public domain) ist oder dass der Urheber seine Zustimmung gegeben hat. Falls dieser Text bereits woanders veröffentlicht wurde, weise bitte auf der Diskussionsseite darauf hin. Bitte beachte, dass alle Eco - Deutsches Wiki-Beiträge automatisch unter der „CC BY-NC-SA 4.0“ stehen (siehe Eco:Urheberrechte für Einzelheiten). Falls du nicht möchtest, dass deine Arbeit hier von anderen verändert und verbreitet wird, dann klicke nicht auf „Seite speichern“.

Um das Wiki vor automatisiertem Bearbeitungsspam zu schützen, bitten wir dich, das folgende hCaptcha zu lösen:

Abbrechen Bearbeitungshilfe (wird in einem neuen Fenster geöffnet)

Die folgende Vorlage wird auf dieser Seite verwendet: