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 = { "Blue Moon To-Go", "By The Stairs", "Ceramic Gate", "Clinic", "Commerce Guild Store", "Construction Junction Shop", "Eufaula Salvage Shop", "Fang and X Clinic", "Game Center Shop", "Hammer Time", "Metalworking Goods", "Ranch Store", "Souvenir Shop", "Tailor Made", "Water Shop", "Water World" ,}

-- -- 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