Jump to content

📢 Please make sure to read our Style Guide before editing. For questions, suggestions, or technical issues, please contact Noah. ✖

Module:ShopListTable: Difference between revisions

From CrabCraft Wiki
Created page with "local p = {} local cargo = mw.ext.cargo function p.Main(frame) local tables = 'base_data' local fields = 'season,basename,owner,basetype,location,dateestablished' local args = { orderBy = 'season ASC, basename ASC', limit = 100 -- Optional; remove or increase if needed } local results = cargo.query(tables, fields, args) local out = {} table.insert(out, '{| class="wikitable sortable plainlinks"') table.insert(out, '! Season !! Base !! Owner !! Type !! Locat..."
 
updated shop type
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:


function p.Main(frame)
function p.Main(frame)
local tables = 'base_data'
local tables = 'shop_data'
local fields = 'season,basename,owner,basetype,location,dateestablished'
local fields = 'season,shopname,shopowner,shoptype,location,dateopened'
local args = {
local args = {
orderBy = 'season ASC, basename ASC',
orderBy = 'season ASC, shopname ASC',
limit = 100 -- Optional; remove or increase if needed
limit = 100 -- Optional; remove or increase if needed
}
}
Line 14: Line 14:
local out = {}
local out = {}
table.insert(out, '{| class="wikitable sortable plainlinks"')
table.insert(out, '{| class="wikitable sortable plainlinks"')
table.insert(out, '! Season !! Base !! Owner !! Type !! Location !! Established')
table.insert(out, '! Season !! Shop !! Owner !! Type !! Location !! Established')


for _, row in ipairs(results) do
for _, row in ipairs(results) do
Line 22: Line 22:
end
end
if row.basename ~= '$1' and row.basename ~= 'Creeper Cove' then
if row.shopname ~= '$1' and row.shopname ~= 'Diamond Emporium' then
table.insert(out, '|-')
table.insert(out, '|-')
table.insert(out, string.format('| %s || [[%s]] || %s || %s || %s || %s',
table.insert(out, string.format('| %s || [[%s]] || %s || %s || %s || %s',
season or '',
season or '',
row.basename or '',
row.shopname or '',
row.owner or '',
row.shopowner or '',
row.basetype or '',
row.shoptype or '',
row.location or '',
row.location or '',
row.dateestablished or ''
row.dateopened or ''
))
))
end
end

Latest revision as of 14:56, 24 June 2025

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

local p = {}
local cargo = mw.ext.cargo

function p.Main(frame)
	local tables = 'shop_data'
	local fields = 'season,shopname,shopowner,shoptype,location,dateopened'
	local args = {
		orderBy = 'season ASC, shopname ASC',
		limit = 100 -- Optional; remove or increase if needed
	}

	local results = cargo.query(tables, fields, args)

	local out = {}
	table.insert(out, '{| class="wikitable sortable plainlinks"')
	table.insert(out, '! Season !! Shop !! Owner !! Type !! Location !! Established')

	for _, row in ipairs(results) do
		local season = ''
		if row.season then 
			season = row.season:sub(3, -3)
		end	
		
		if row.shopname ~= '$1' and row.shopname ~= 'Diamond Emporium' then
		table.insert(out, '|-')
		table.insert(out, string.format('| %s || [[%s]] || %s || %s || %s || %s',
			season or '',
			row.shopname or '',
			row.shopowner or '',
			row.shoptype or '',
			row.location or '',
			row.dateopened or ''
		))
		end
	end

	table.insert(out, '|}')
	return table.concat(out, '\n')
end

return p