Module:Crafting: Difference between revisions
Jump to navigation
Jump to search
TheGmaster (talk | contribs) No edit summary |
TheGmaster (talk | contribs) No edit summary Tag: Manual revert |
||
(16 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
-- Parameters passed to the template the function was invoked in | -- Parameters passed to the template the function was invoked in | ||
local query = frame | local query = frame.args[6] -- {{PAGENAME}} = Crafting Skill or Ingredient | ||
local mode = string.lower(frame | local mode = string.lower(frame.args[7]) -- Item/Ingredient/Skill/Category | ||
local exclude = frame | local exclude = frame.args[8] -- string to not include | ||
local recipeSnippet = "<tr><td>"..categoryString.."<td>"..itemImageName.."<br>"..itemName.."<td>"..ingredientsString.."<td>"..skillString | local recipeSnippet = "<tr><td>"..categoryString.."<td>"..itemImageName.."<br>"..itemName.."<td>"..ingredientsString.."<td>"..skillString | ||
Line 25: | Line 25: | ||
if skillQuery and not string.find(skillString,exclude) then | if skillQuery and not string.find(skillString,exclude) then | ||
return recipeSnippet | return recipeSnippet | ||
end | end | ||
elseif mode == "ingredient" then | elseif mode == "ingredient" then | ||
if ingredientQuery and not string.find(ingredientsString,exclude) then | if ingredientQuery and not string.find(ingredientsString,exclude) then | ||
return recipeSnippet | return recipeSnippet | ||
end | end | ||
elseif mode == "item" then | elseif mode == "item" then | ||
if itemQuery and not string.find(itemName,exclude) then | if itemQuery and not string.find(itemName,exclude) then | ||
return recipeSnippet | return recipeSnippet | ||
end | end | ||
elseif mode == "category" then | elseif mode == "category" then | ||
if categoryQuery and not string.find(categoryString,exclude) then | if categoryQuery and not string.find(categoryString,exclude) then | ||
return recipeSnippet | return recipeSnippet | ||
end | end | ||
elseif mode == "all" then | |||
return "<tr | return recipeSnippet | ||
else | |||
return "<tr><td>Error: Ensure the query (parameter 1) is spelled correctly and the mode (parameter 2) is set to ingredient/item/skill/category" | |||
end | end | ||
end | end | ||
return p | return p |
Latest revision as of 03:46, 18 August 2024
Documentation for this module may be created at Module:Crafting/doc
local p = {} function p.recipe( frame ) -- Parameters passed when the function is invoked local categoryString = frame.args[1] -- i.e. Potion Bundles local itemImageName = frame.args[2] -- i.e. lethalpoisonpotion.png local itemName = frame.args[3] -- i.e. Lethal Poison Potion local ingredientsString = frame.args[4] -- i.e. 10 [[Magery#Reagents|Nightshade]]<br>1 [[Empty Bottle]] local skillString = frame.args[5] -- i.e. 110 Alchemy -- Parameters passed to the template the function was invoked in local query = frame.args[6] -- {{PAGENAME}} = Crafting Skill or Ingredient local mode = string.lower(frame.args[7]) -- Item/Ingredient/Skill/Category local exclude = frame.args[8] -- string to not include local recipeSnippet = "<tr><td>"..categoryString.."<td>"..itemImageName.."<br>"..itemName.."<td>"..ingredientsString.."<td>"..skillString local skillQuery = string.find(skillString,query) local ingredientQuery = string.find(ingredientsString,query) local itemQuery = string.find(itemName,query) local categoryQuery = string.find(categoryString,query) if mode == "skill" then if skillQuery and not string.find(skillString,exclude) then return recipeSnippet end elseif mode == "ingredient" then if ingredientQuery and not string.find(ingredientsString,exclude) then return recipeSnippet end elseif mode == "item" then if itemQuery and not string.find(itemName,exclude) then return recipeSnippet end elseif mode == "category" then if categoryQuery and not string.find(categoryString,exclude) then return recipeSnippet end elseif mode == "all" then return recipeSnippet else return "<tr><td>Error: Ensure the query (parameter 1) is spelled correctly and the mode (parameter 2) is set to ingredient/item/skill/category" end end return p