Module:Crafting: Difference between revisions
Jump to navigation
Jump to search
TheGmaster (talk | contribs) No edit summary |
TheGmaster (talk | contribs) No edit summary |
||
Line 47: | Line 47: | ||
end | end | ||
else | else | ||
return "<tr | 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 |
Revision as of 21:08, 6 June 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 else p = "" end elseif mode == "ingredient" then if ingredientQuery and not string.find(ingredientsString,exclude) then return recipeSnippet else p = "" end elseif mode == "item" then if itemQuery and not string.find(itemName,exclude) then return recipeSnippet else p = "" end elseif mode == "category" then if categoryQuery and not string.find(categoryString,exclude) then return recipeSnippet else p = "" end 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