Module:IS

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

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

-- Original IS template: -- ]]

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

--Find the item name throughout the table of item pages to link a page if link ~= "nolink" then --Skip the link finding part if argument 2 is "nolink" 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 link = "|link=" ..page.pagename.."#"..item --"link" becomes the name of the page the item is listed on				end end end end

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

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

return p

-- print(p.main)