<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ASMW_table</id>
	<title>Module:SMW table - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ASMW_table"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:SMW_table&amp;action=history"/>
	<updated>2026-04-30T06:36:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:SMW_table&amp;diff=38435&amp;oldid=prev</id>
		<title>Alex at 10:23, 17 October 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:SMW_table&amp;diff=38435&amp;oldid=prev"/>
		<updated>2024-10-17T10:23:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:23, 17 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 135:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 135:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	mw.logObject(obj)&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	mw.logObject(obj)&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	assert(obj, &quot;No &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mw.&lt;/del&gt;pages were found matching your query&quot;)&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	assert(obj, &quot;No pages were found matching your query&quot;)&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	for _, page in ipairs(obj) do&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	for _, page in ipairs(obj) do&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:SMW_table&amp;diff=35161&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {}  local yesno = require(&#039;Module:Yesno&#039;)  function header(tbl, cols, fmts, imgs, types) 	local tr = tbl:tag(&#039;tr&#039;) 	if cols[0] ~= nil then 		tr:tag(&#039;th&#039;):addClass(&#039;unsortable&#039;) 	end     tr:tag(&#039;th&#039;):attr(&#039;data-sort-type&#039;, &#039;text&#039;):css(&#039;text-align&#039;, &#039;left&#039;):wikitext(&#039;Name&#039;) 	for i=1,#cols do 		local ctype = types[i] or types[&#039;def&#039;] 		local img = imgs[i] or imgs[&#039;def&#039;] 		local fmt = fmts[i] or fmts[&#039;def&#039;] 		tr:tag(&#039;th&#039;):attr(&#039;data-sort-type&#039;, ctype):wikitext(strin...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:SMW_table&amp;diff=35161&amp;oldid=prev"/>
		<updated>2024-10-16T23:13:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  local yesno = require(&amp;#039;Module:Yesno&amp;#039;)  function header(tbl, cols, fmts, imgs, types) 	local tr = tbl:tag(&amp;#039;tr&amp;#039;) 	if cols[0] ~= nil then 		tr:tag(&amp;#039;th&amp;#039;):addClass(&amp;#039;unsortable&amp;#039;) 	end     tr:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;data-sort-type&amp;#039;, &amp;#039;text&amp;#039;):css(&amp;#039;text-align&amp;#039;, &amp;#039;left&amp;#039;):wikitext(&amp;#039;Name&amp;#039;) 	for i=1,#cols do 		local ctype = types[i] or types[&amp;#039;def&amp;#039;] 		local img = imgs[i] or imgs[&amp;#039;def&amp;#039;] 		local fmt = fmts[i] or fmts[&amp;#039;def&amp;#039;] 		tr:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;data-sort-type&amp;#039;, ctype):wikitext(strin...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
function header(tbl, cols, fmts, imgs, types)&lt;br /&gt;
	local tr = tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	if cols[0] ~= nil then&lt;br /&gt;
		tr:tag(&amp;#039;th&amp;#039;):addClass(&amp;#039;unsortable&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
    tr:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;data-sort-type&amp;#039;, &amp;#039;text&amp;#039;):css(&amp;#039;text-align&amp;#039;, &amp;#039;left&amp;#039;):wikitext(&amp;#039;Name&amp;#039;)&lt;br /&gt;
	for i=1,#cols do&lt;br /&gt;
		local ctype = types[i] or types[&amp;#039;def&amp;#039;]&lt;br /&gt;
		local img = imgs[i] or imgs[&amp;#039;def&amp;#039;]&lt;br /&gt;
		local fmt = fmts[i] or fmts[&amp;#039;def&amp;#039;]&lt;br /&gt;
		tr:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;data-sort-type&amp;#039;, ctype):wikitext(string.format(fmt, img, cols[i]))&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function row(tbl, data, cols, seps)&lt;br /&gt;
	local tr = tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	name = mw.text.split(data[1], &amp;#039;#&amp;#039;, true)&lt;br /&gt;
	if name[2] then name[2] = name[2]:gsub(&amp;#039;_&amp;#039;, &amp;#039; &amp;#039;) else name[2] = &amp;#039;&amp;amp;nbsp;&amp;#039; end&lt;br /&gt;
	if cols[0] then&lt;br /&gt;
		local col0 = tr:tag(&amp;#039;td&amp;#039;):css(&amp;#039;max-height&amp;#039;, &amp;#039;64px&amp;#039;)&lt;br /&gt;
		-- seps[0] stores the type of col0, because data0 doesn&amp;#039;t get passed to this function.&lt;br /&gt;
		if seps[0] == nil or seps[0] == &amp;#039;image&amp;#039; then&lt;br /&gt;
			local subject = data[1] or &amp;#039;&amp;#039;&lt;br /&gt;
			if type(data[cols[0]]) == &amp;#039;string&amp;#039; then&lt;br /&gt;
				col0:wikitext(string.format(&amp;#039;[[%s|x64px|link=|%s]]&amp;#039;, data[cols[0]], subject))&lt;br /&gt;
			elseif type(data[&amp;#039;All &amp;#039;..cols[0]]) == &amp;#039;string&amp;#039; then&lt;br /&gt;
				col0:wikitext(string.format(&amp;#039;[[%s|x64px|link=|%s]]&amp;#039;, data[&amp;#039;All &amp;#039;..cols[0]], subject))&lt;br /&gt;
			elseif type(data[cols[0]]) == &amp;#039;table&amp;#039; then -- last image to show the image for 5, if possible.&lt;br /&gt;
				col0:wikitext(string.format(&amp;#039;[[%s|x64px|link=|%s]]&amp;#039;, data[cols[0]][#data[cols[0]]], subject))&lt;br /&gt;
			elseif type(data[&amp;#039;All &amp;#039;..cols[0]]) == &amp;#039;table&amp;#039; then&lt;br /&gt;
				col0:wikitext(string.format(&amp;#039;[[%s|x64px|link=|%s]]&amp;#039;, data[&amp;#039;All &amp;#039;..cols[0]][#data[&amp;#039;All &amp;#039;..cols[0]]], subject))&lt;br /&gt;
			else&lt;br /&gt;
				col0:wikitext(&amp;#039;error&amp;#039;)&lt;br /&gt;
				mw.log(&amp;#039;error&amp;#039;)&lt;br /&gt;
				mw.logObject({data, cols[0]})&lt;br /&gt;
			end&lt;br /&gt;
		elseif seps[0] == &amp;#039;link&amp;#039; then&lt;br /&gt;
			col0:wikitext(&amp;#039;[[:&amp;#039;..data[cols[0]]..&amp;#039;]]&amp;#039;)&lt;br /&gt;
		else&lt;br /&gt;
			col0:wikitext(data[cols[0]])&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	tr:tag(&amp;#039;td&amp;#039;):wikitext(string.format(&amp;#039;[[%s|%s]]&amp;lt;br/&amp;gt;\&amp;#039;\&amp;#039;%s\&amp;#039;\&amp;#039;&amp;#039;, data[1], name[1], name[2]))&lt;br /&gt;
	for i, col in ipairs(cols) do&lt;br /&gt;
		local val = data[col]&lt;br /&gt;
		td = tr:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		if col == &amp;#039;Is members only&amp;#039; then&lt;br /&gt;
			if yesno(val, true) then&lt;br /&gt;
				td:wikitext(&amp;#039;[[File:Member icon.png|link=|Members]]&amp;#039;)&lt;br /&gt;
			else&lt;br /&gt;
				td:wikitext(&amp;#039;[[File:Free-to-play icon.png|link=|Free-to-play]]&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
		elseif type(val) == &amp;#039;table&amp;#039; then&lt;br /&gt;
			-- multiple values provided; join using the provided separator&lt;br /&gt;
			td:wikitext(table.concat(val, seps[i] or seps[&amp;#039;def&amp;#039;]))&lt;br /&gt;
		else&lt;br /&gt;
			td:wikitext(val)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	local cols = {}&lt;br /&gt;
	local headers = {[&amp;#039;def&amp;#039;] = &amp;#039;[[File:%s|link=|%s]]&amp;#039;} -- default header format: image with img and page query&lt;br /&gt;
	local imgs = {[&amp;#039;def&amp;#039;] = &amp;#039;Unknown NPC.png|x30px&amp;#039;} -- default image: question marks; 30px high&lt;br /&gt;
	local coltypes = {[&amp;#039;def&amp;#039;] = &amp;#039;number&amp;#039;} -- default sort: string&lt;br /&gt;
	local seps = {[&amp;#039;def&amp;#039;] = &amp;#039;, &amp;#039;} -- default array separator string: comma&lt;br /&gt;
	local query&lt;br /&gt;
	-- parse all expected parameters&lt;br /&gt;
	for param, arg in pairs(args) do&lt;br /&gt;
		local col = string.match(param, &amp;quot;col(%d+)&amp;quot;)&lt;br /&gt;
		local header = string.match(param, &amp;quot;header(%d*)&amp;quot;)&lt;br /&gt;
		local img = string.match(param, &amp;quot;img(%d+)&amp;quot;)&lt;br /&gt;
		local coltype = string.match(param, &amp;quot;data(%d*)&amp;quot;)&lt;br /&gt;
		local sep = string.match(param, &amp;quot;sep(%d*)&amp;quot;)&lt;br /&gt;
		if param == 1 then&lt;br /&gt;
			-- param 1: the query&lt;br /&gt;
			query = {arg}&lt;br /&gt;
		elseif col then&lt;br /&gt;
			-- property to add to a col X&lt;br /&gt;
			cols[tonumber(col)] = arg&lt;br /&gt;
		elseif img then&lt;br /&gt;
			-- column header img X&lt;br /&gt;
			imgs[tonumber(img)] = arg&lt;br /&gt;
		elseif header == &amp;#039;&amp;#039; then&lt;br /&gt;
			-- default header format&lt;br /&gt;
			headers[&amp;#039;def&amp;#039;] = arg&lt;br /&gt;
		elseif header then&lt;br /&gt;
			-- header X format&lt;br /&gt;
			headers[tonumber(header)] = arg&lt;br /&gt;
		elseif coltype == &amp;#039;&amp;#039; then&lt;br /&gt;
			-- default sorting type&lt;br /&gt;
			coltypes[&amp;#039;def&amp;#039;] = arg&lt;br /&gt;
		elseif coltype then&lt;br /&gt;
			-- sorting type for col X&lt;br /&gt;
			coltypes[tonumber(coltype)] = arg&lt;br /&gt;
		elseif sep == &amp;#039;&amp;#039; then&lt;br /&gt;
			-- default array string separator&lt;br /&gt;
			seps[&amp;#039;def&amp;#039;] = arg&lt;br /&gt;
		elseif sep then&lt;br /&gt;
			-- array X string separator&lt;br /&gt;
			seps[tonumber(sep)] = arg&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- store col type for column 0 in seps because that is passed on to the row() function&lt;br /&gt;
	seps[0] = coltypes[0]&lt;br /&gt;
&lt;br /&gt;
	local tbl = mw.html.create(&amp;#039;table&amp;#039;):addClass(&amp;#039;wikitable sortable sticky-header&amp;#039;)&lt;br /&gt;
	if args.class then&lt;br /&gt;
		tbl:addClass(args.class)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set header&lt;br /&gt;
	header(tbl, cols, headers, imgs, coltypes)&lt;br /&gt;
&lt;br /&gt;
	table.insert(query, &amp;#039;?=#-&amp;#039;) -- return plain article name without link&lt;br /&gt;
	table.insert(query, &amp;#039;limit=&amp;#039;..tostring(tonumber(args.limit) or &amp;#039;100&amp;#039;))&lt;br /&gt;
	-- col 0 is a special col for images and the like&lt;br /&gt;
	if cols[0] ~= nil then&lt;br /&gt;
		table.insert(query, &amp;#039;?&amp;#039; .. cols[0] .. &amp;#039;#-&amp;#039;)&lt;br /&gt;
		table.insert(query, &amp;#039;?All &amp;#039; .. cols[0] .. &amp;#039;#-&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	for _, col in ipairs(cols) do&lt;br /&gt;
		table.insert(query, &amp;#039;?&amp;#039; .. col)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get all SMW data&lt;br /&gt;
	mw.logObject(query)&lt;br /&gt;
	local obj = mw.smw.ask(query)&lt;br /&gt;
	mw.logObject(obj)&lt;br /&gt;
	&lt;br /&gt;
	assert(obj, &amp;quot;No mw.pages were found matching your query&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	for _, page in ipairs(obj) do&lt;br /&gt;
		row(tbl, page, cols, seps)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return tbl&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>