Module:Crafting: Difference between revisions

From UO Outlands Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Tag: Manual revert
Line 24: Line 24:
if mode == "skill" then
if mode == "skill" then
if skillQuery and not string.find(skillString,exclude) then
if skillQuery and not string.find(skillString,exclude) then
return recipeSnippet
p = 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
p = 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
p = 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
p = recipeSnippet
end
end
else
else
Line 42: Line 42:
end
end
end
end
return p

Revision as of 20:11, 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><br><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
			p = recipeSnippet
		end
	elseif mode == "ingredient" then
		if ingredientQuery and not string.find(ingredientsString,exclude) then
			p = recipeSnippet
		end
	elseif mode == "item" then
		if itemQuery and not string.find(itemName,exclude) then
			p = recipeSnippet
		end
	elseif mode == "category" then
		if categoryQuery and not string.find(categoryString,exclude) then
			p = 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