Jump to content

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

Module:BaseListTable: Difference between revisions

From CrabCraft Wiki
base name links
fixed error on page
Line 17: Line 17:


for _, row in ipairs(results) do
for _, row in ipairs(results) do
local season = row.season:sub(3, -3)
if row.season then
local season = row.season:sub(3, -3)
end
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',

Revision as of 14:02, 24 June 2025

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

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 !! Location !! Established')

	for _, row in ipairs(results) do
		if row.season then 
			local season = row.season:sub(3, -3)
		end	
		
		table.insert(out, '|-')
		table.insert(out, string.format('| %s || [[%s]] || %s || %s || %s || %s',
			season or '',
			row.basename or '',
			row.owner or '',
			row.basetype or '',
			row.location or '',
			row.dateestablished or ''
		))
	end

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

return p