Module:Sandbox/User:Alsang/PriceChecker: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
local results = mw.smw.ask(query)
local results = mw.smw.ask(query)
local out = {}
local out = {'List of items:'}
for _,item in ipairs(results) do
for _,item in ipairs(results) do
local i = tonumber(item.InfoboxValue)
local i = tonumber(item.InfoboxValue)
Line 35: Line 35:
end
end
end
end
table.insert(out,'End of List')
return table.concat(out, '<br>')
return table.concat(out, '<br>')

Latest revision as of 20:25, 9 January 2025

Module documentation
This documentation is transcluded from Module:Sandbox/User:Alsang/PriceChecker/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Sandbox/User:Alsang/PriceChecker/doc. [edit]
Module:Sandbox/User:Alsang/PriceChecker's function main is invoked by Template:Sandbox/User:Alsang/PriceChecker.

local p = {}

-- non dynamic module, no inputs
function p.main()
	-- returns only directly needed parameter needed for the row,
	-- other parameters are determined by subqueries of chained pages
	local query = {
		'[[-Sold item.Shop sell price::+]]',
		'?=Name',
		'?-Sold item.Shop sell price=ShopValue',
		'?Value=InfoboxValue',
		'limit = 500'
	}

	local results = mw.smw.ask(query)
	
	local out = {'List of items:'}
	for _,item in ipairs(results) do
		local i = tonumber(item.InfoboxValue)
		local s = item.ShopValue
		local add = true
		if type(s)=='string' then
			if i==tonumber(s) or not(tonumber(s)) then
				add = false
			end
		elseif type(s)=='table' then
			for _,shop in ipairs(s) do
				if i==tonumber(shop)  or not(tonumber(shop)) then
					add = false
				end
			end
		end
		if add then
			table.insert(out,item.Name)
		end
	end
	table.insert(out,'End of List')
	
	return table.concat(out, '<br>')
	
end

return p