Module:IS

local getArgs = require('Module:Arguments').getArgs local p = {}

function p.main(frame) local args = getArgs(frame) return p._main(args) end

function p._main(args) local pages = mw.loadData('Module:IS/pages') --Returns a table containing a table for each item page's name and the items on them

local item = args[1] or "" --Passed argument is the name of the item who's sprite we want local link = args[2] or "" --Page the sprite should link to. Can be removed or added manually

--Find the item name throughout the table of item pages to link a page if args[2] == nil then --If statement to skip the link finding part if argument 2 isn't empty for _, page in pairs(pages) do --Iterate each item page table in "pages" for _, i in pairs (page.items) do --Iterate its table of items if i == item then --If "item" matches if item == "Mystery Egg" then link = "|link="..page.pagename elseif item == "Heart Slate" then link = "|link=Heart Slates" else link = "|link=" ..page.pagename.."#"..item --"link" becomes the name of the page the item is listed on					end end end end end --Manual link if args[2] ~= nil and link ~= "nolink" then --If argument 2 isn't empty and also isn't "nolink" link = "|link="..link --Passed arg becomes the linked page end

--Remove ` in item name if string.match(item, "`") then item = string.gsub(item, "`", "") end

if mw.getCurrentFrame:callParserFunction("filepath", "" .. item .. ".png") ~= "" then if link == "nolink" then --Omit the automatic link if argument 2 is "nolink" return "" else return "" end else return "" end end

return p