Editing Module:GetRecipes
From Eco - English Wiki
Your changes will be displayed to readers once an authorized user accepts them. (help)
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 10: | Line 10: | ||
-- get args from the Template | -- get args from the Template | ||
local args = Utils.normaliseArgs(frame) | local args = Utils.normaliseArgs(frame) | ||
-- assign variables for item, table, and group | |||
local item = args.item | |||
local table = args.table | |||
local group = args.group | |||
-- load list of recipes | -- load list of recipes | ||
local completeList = require("Module:CraftingRecipes") | local completeList = require("Module:CraftingRecipes") | ||
Line 31: | Line 31: | ||
local parser = require("Module:CraftingParser") | local parser = require("Module:CraftingParser") | ||
-- priority: item | -- priority: item > table > group | ||
if item ~= nil then | if item ~= nil then | ||
if productsList[item] ~= nil then | |||
-- HACK Attempt to handle issue with tool recipes | |||
if #productsList[item] == 1 and productsList[item][1] == '' then | |||
productsList[item] = {item} | |||
end | end | ||
local built = 1 | |||
for _, itemProduct in ipairs(productsList[item]) do | |||
if (itemProduct ~= '' and recipeList[itemProduct] ~= nil) then | |||
products[built] = recipeList[itemProduct] | |||
built = built + 1 | |||
for _, | |||
if | |||
end | end | ||
end | end | ||
end | end | ||
if ingredientsList[item] ~= nil then | |||
-- HACK Attempt to handle issue with tool recipes | |||
if #ingredientsList[item] == 1 and ingredientsList[item][1] == '' then | |||
ingredientsList[item] = {item} | |||
end | end | ||
local built = 1 | |||
for _, itemIngredient in ipairs(ingredientsList[item]) do | |||
for _, itemIngredient in | |||
if itemIngredient ~= '' then | if itemIngredient ~= '' then | ||
if recipeList[itemIngredient] ~= nil then | |||
ingredients[built] = recipeList[itemIngredient] | |||
built = built + 1 | |||
-- HACK: Skill books don't show us as a product of research pages, only the skill name. | |||
elseif recipeList[itemIngredient .. ' Skill Book'] ~= nil then | |||
ingredients[built] = recipeList[itemIngredient .. ' Skill Book'] | |||
built = built + 1 | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
return parser.formattedItem(products, ingredients, | |||
return parser.formattedItem(products, ingredients, item) | |||
elseif | elseif table ~= nil then | ||
for num = 1, #tableList[table] do | |||
recipes[num] = recipeList[tableList[table][num]] | |||
end | end | ||
return parser.formattedTable(recipes, | return parser.formattedTable(recipes, table) | ||
else | else |