Module:Crafting: Difference between revisions
Jump to navigation
Jump to search
TheGmaster (talk | contribs) mNo edit summary |
TheGmaster (talk | contribs) mNo edit summary |
||
| Line 40: | Line 40: | ||
elseif mode == "all" then | elseif mode == "all" then | ||
return recipeSnippet | return recipeSnippet | ||
end | end | ||
end | end | ||
return p | return p | ||
Revision as of 21:55, 11 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
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
end
end
return p