<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AXpsoc</id>
	<title>Module:Xpsoc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AXpsoc"/>
	<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Module:Xpsoc&amp;action=history"/>
	<updated>2026-04-19T05:20:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://compusofia.com/w/index.php?title=Module:Xpsoc&amp;diff=7231&amp;oldid=prev</id>
		<title>Majestix: Created page with &quot;-- This module implements {{xpsoc}}.  local p = {}  local function makeInvocation(name, args, useNoWiki) 	-- This function makes a template invocation from the name and the arguments 	-- given.  	-- Copy the invocation args and convert magic words. 	-- We need to make a copy of the table rather than just using the original, 	-- as some of the values may be erased when building the invocation. 	local invArgs = {} 	for k, v in pairs(args) do 		invArgs[k] = v 	end  	-- Get...&quot;</title>
		<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Module:Xpsoc&amp;diff=7231&amp;oldid=prev"/>
		<updated>2026-04-17T06:08:52Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- This module implements {{xpsoc}}.  local p = {}  local function makeInvocation(name, args, useNoWiki) 	-- This function makes a template invocation from the name and the arguments 	-- given.  	-- Copy the invocation args and convert magic words. 	-- We need to make a copy of the table rather than just using the original, 	-- as some of the values may be erased when building the invocation. 	local invArgs = {} 	for k, v in pairs(args) do 		invArgs[k] = v 	end  	-- Get...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{xpsoc}}.&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function makeInvocation(name, args, useNoWiki)&lt;br /&gt;
	-- This function makes a template invocation from the name and the arguments&lt;br /&gt;
	-- given.&lt;br /&gt;
&lt;br /&gt;
	-- Copy the invocation args and convert magic words.&lt;br /&gt;
	-- We need to make a copy of the table rather than just using the original,&lt;br /&gt;
	-- as some of the values may be erased when building the invocation.&lt;br /&gt;
	local invArgs = {}&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		invArgs[k] = v&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get the separators to use.&lt;br /&gt;
	local seps = {&lt;br /&gt;
		openb = &amp;#039;{{&amp;#039;,&lt;br /&gt;
		closeb = &amp;#039;}}&amp;#039;,&lt;br /&gt;
		pipe = &amp;#039;|&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
	if useNoWiki then&lt;br /&gt;
		for k, v in pairs(seps) do&lt;br /&gt;
			seps[k] = mw.text.nowiki(v)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Build the invocation body with numbered args first, then named.&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	ret[#ret + 1] = seps.openb&lt;br /&gt;
	ret[#ret + 1] = name&lt;br /&gt;
	for k, v in ipairs(invArgs) do&lt;br /&gt;
		if v:find(&amp;#039;=&amp;#039;, 1, true) then&lt;br /&gt;
			-- Likely something like 1=foo=bar, we need to do it as a named arg&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
		ret[#ret + 1] = seps.pipe&lt;br /&gt;
		ret[#ret + 1] = v&lt;br /&gt;
		invArgs[k] = nil -- Erase the key so that we don&amp;#039;t add the value twice&lt;br /&gt;
	end&lt;br /&gt;
	for k, v in pairs(invArgs) do&lt;br /&gt;
		ret[#ret + 1] = seps.pipe&lt;br /&gt;
		ret[#ret + 1] = k&lt;br /&gt;
		ret[#ret + 1] = &amp;#039;=&amp;#039;&lt;br /&gt;
		ret[#ret + 1] = v&lt;br /&gt;
	end&lt;br /&gt;
	ret[#ret + 1] = seps.closeb&lt;br /&gt;
&lt;br /&gt;
	return table.concat(ret)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args, frame)&lt;br /&gt;
	frame = frame or mw.getCurrentFrame()&lt;br /&gt;
&lt;br /&gt;
	-- Get the invocation arguments.&lt;br /&gt;
	local name = args[1]&lt;br /&gt;
	if not name then&lt;br /&gt;
		error(&amp;#039;no template name passed to xpsoc&amp;#039;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	local invArgs = {}&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		if k ~= 1 then&lt;br /&gt;
			if type(k) == &amp;#039;number&amp;#039; then&lt;br /&gt;
				invArgs[k - 1] = v&lt;br /&gt;
			else&lt;br /&gt;
				local num = k:match(&amp;#039;^n([1-9][0-9]*)$&amp;#039;)&lt;br /&gt;
				if num then&lt;br /&gt;
					invArgs[args[k]] = args[&amp;#039;v&amp;#039; .. num]&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local invocation = makeInvocation(name, invArgs, true)&lt;br /&gt;
	local gives = args.gives or mw.language.getContentLanguage():getArrow(&amp;#039;forwards&amp;#039;)&lt;br /&gt;
	local result = frame:preprocess(makeInvocation(name, invArgs))&lt;br /&gt;
	&lt;br /&gt;
	return string.format(&amp;#039;&amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; %s %s&amp;#039;, invocation, gives, result)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	return p._main(frame:getParent().args, frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Majestix</name></author>
	</entry>
</feed>