Module:Crafting: Difference between revisions
Jump to navigation
Jump to search
TheGmaster (talk | contribs) (Created page with "local p = {} function p.recipe( frame ) -- Parameters passed when the function is invoked local categoryString = frame.args[1] -- i.e. Potion Bundles local skillString = frame.args[2] -- i.e. 110 Alchemy local itemImageName = frame.args[3] -- i.e. lethalpoisonpotion.png local itemName = frame.args[4] -- i.e. Lethal Poison Potion local ingredientsString = frame.args[5] -- i.e. 10 Nightshade<br>1 Empty Bottle -- Par...") |
TheGmaster (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
-- Parameters passed when the function is invoked | -- Parameters passed when the function is invoked | ||
local categoryString = frame.args[1] -- i.e. Potion Bundles | local categoryString = frame.args[1] -- i.e. Potion Bundles | ||
local | local itemImageName = frame.args[2] -- i.e. lethalpoisonpotion.png | ||
local itemName = frame.args[3] -- i.e. Lethal Poison Potion | |||
local itemName = frame.args[ | local ingredientsString = frame.args[4] -- i.e. 10 [[Magery#Reagents|Nightshade]]<br>1 [[Empty Bottle]] | ||
local ingredientsString = frame.args[ | local skillString = frame.args[5] -- i.e. 110 Alchemy | ||
-- Parameters passed to the template the function was invoked in | -- Parameters passed to the template the function was invoked in |
Revision as of 02:27, 1 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><br><td>"..categoryString.."<td>[[File:"..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 else return "<tr><br><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