Module:Cron/drops

From RuneRealm Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Cron/drops/doc

local exchange = require('Module:Exchange')

local p = {}

function p.getPages(offset)
	local ask = mw.smw.ask("[[-Dropped item::+]]|?#-=n|?Is members only|?High Alchemy value|limit=500|offset=" .. offset)
	pages = {}
	for _, data in ipairs(ask) do
		mw.logObject(data)
		local name = data["n"]
		pages[name] = {data['Is members only'], data['High Alchemy value']}
	end
	return pages
end

function p.each(page, data)

end

function p.main(frame)
	local offset = frame.args.offset
	local pages = p.getPages(offset)
	
	for page, data in pairs(pages) do
		p.each(page, data)
		if #data == 0 then
			pages[page] = nil
		end
		-- if #data == 1 then
		-- 	pages[page] = data[1]
		-- end
	end
	
	local ret = mw.dumpObject(pages):gsub('table#%d+', '')
	return ret
end

return p