Module:ItemBuybackLocations

-- -- Module:ItemBuybackLocations -- -- Parses all the store's buyback subpages for the item to see which stores buy it. -- Returns a list of all valid stores or Cannot be sold -- local Self = {}                            -- table of functions local Helper = require("Module:Helper")    -- basic helper functions local ustr = mw.ustring                    -- quick/short access to ustring table

-- -- Constants -- local STORES = { "A&G Construction Store", "Alice's Flower Shop", "Best Brother", "Clothing Store", "Dr. Xu's Clinic", "Farm Store", "Food Store", "Harbor Trade Station", "Martha's Bakery", "South Block Trade Post", "Temporary Store", "Total Tools", }

-- -- GetList -- Self.GetList = function(frame) return Self.GetListMain(Helper.GetArgs(frame), frame) end

function Self.GetListMain(args, frame) local item = Helper.EscapeMagicCharacters(args[1]) local found = false local txt = "" for _, location in ipairs(STORES) do       local content = mw.title.new(location.."/Buybacks"):getContent if content then if ustr.match(content, "%|%s*"..item.."%s*[%|}]") then found = true txt = txt.." "..location.."" end end end if found then return ustr.sub(txt, 5) --strip off the first else return "Cannot be sold at a store " end end

-- -- Required for Modules to function -- return Self