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 2: | Line 2: | ||
local p = {} | local p = {} | ||
-- Grabs args from the parent frame | |||
-- Trims and parses the args into a table, then returns the table | |||
-- | function norm() | ||
local origArgs = mw.getCurrentFrame():getParent().args | |||
local args = {} | |||
for k, v in pairs( origArgs ) do | |||
v = mw.text.trim( tostring( v ) ) | |||
if v ~= '' then | |||
args[k] = v | |||
function | |||
local | |||
end | end | ||
end | end | ||
return args | |||
end | |||
local | -- 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 | |||
-- | -- 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 > table > group | |||
if item ~= nil then | |||
test = item .. '\n' | |||
if productsList[item] ~= nil then | |||
test = test .. 'PRODUCTS TOTAL ' .. tostring(#productsList) .. ' RECIPES \n' | |||
for num = 1, #productsList do | |||
test = test .. tostring(productsList[item][num]) .. '\n' | |||
--if (productsList[item][num] ~= '' and recipeList[productsList[item][num]] ~= nil) then | |||
--products[num] = recipeList[productsList[item][num]] | |||
--end | |||
end | |||
end | |||
if ingredientsList[item] ~= nil then | |||
test = test .. 'INGEDIENTS TOTAL' .. tostring(#ingredientsList) .. ' RECIPES \n' | |||
for num = 1, #ingredientsList do | |||
test = test .. tostring(ingredientsList[item][num]) .. '\n' | |||
--if (ingredientsList[item][num] ~= '' and recipeList[ingredientsList[item][num]] ~= nil) then | |||
--ingredients[num] = recipeList[ingredientsList[item][num]] | |||
--end | |||
end | |||
end | |||
return test | |||
--return parser.formattedItem( products, ingredients, item ) | |||
--elseif table ~= nil then | |||
--for num = 1, #tableList[table] do | |||
--recipes[num] = recipeList[tableList[table][num]] | |||
--end | |||
--return parser.formattedTable( recipes, table ) | |||
return | |||
else | |||
return 'Invalid use of parameters, please see [[Template:GetRecipes]].' | |||
end | end | ||
end | end | ||
return p | return p |