<?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%3ARequired_for_completing</id>
	<title>Module:Required for completing - 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%3ARequired_for_completing"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Required_for_completing&amp;action=history"/>
	<updated>2026-05-01T01:15:34Z</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:Required_for_completing&amp;diff=35095&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;--&lt;nowiki&gt; -- essentially the inverse of Module:Questreq, though with the option of expanding into other types of reqs (eg achievements - will need SMW work for those though) local quests = mw.loadData(&#039;Module:Questreq/data&#039;) local p = {} local yesno = require(&#039;Module:Yesno&#039;)  function _sortFunc(a,b) 	local _a, _b 	_a = tostring(a):lower():gsub(&#039;^full:&#039;, &#039;&#039;):gsub(&#039;^started:&#039;, &#039;&#039;) 	_b = tostring(b):lower():gsub(&#039;^full:&#039;, &#039;&#039;):gsub(&#039;^started:&#039;, &#039;&#039;) 	return _a &lt; _b end...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Required_for_completing&amp;diff=35095&amp;oldid=prev"/>
		<updated>2024-10-16T23:12:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--&amp;lt;nowiki&amp;gt; -- essentially the inverse of &lt;a href=&quot;/w/Module:Questreq&quot; title=&quot;Module:Questreq&quot;&gt;Module:Questreq&lt;/a&gt;, though with the option of expanding into other types of reqs (eg achievements - will need SMW work for those though) local quests = mw.loadData(&amp;#039;Module:Questreq/data&amp;#039;) local p = {} local yesno = require(&amp;#039;Module:Yesno&amp;#039;)  function _sortFunc(a,b) 	local _a, _b 	_a = tostring(a):lower():gsub(&amp;#039;^full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^started:&amp;#039;, &amp;#039;&amp;#039;) 	_b = tostring(b):lower():gsub(&amp;#039;^full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^started:&amp;#039;, &amp;#039;&amp;#039;) 	return _a &amp;lt; _b end...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&amp;lt;nowiki&amp;gt;&lt;br /&gt;
-- essentially the inverse of [[Module:Questreq]], though with the option of expanding into other types of reqs (eg achievements - will need SMW work for those though)&lt;br /&gt;
local quests = mw.loadData(&amp;#039;Module:Questreq/data&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
function _sortFunc(a,b)&lt;br /&gt;
	local _a, _b&lt;br /&gt;
	_a = tostring(a):lower():gsub(&amp;#039;^full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	_b = tostring(b):lower():gsub(&amp;#039;^full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	return _a &amp;lt; _b&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function getQuests(q)&lt;br /&gt;
	local qs = {}&lt;br /&gt;
	q = tostring(q)&lt;br /&gt;
	q = q:lower()&lt;br /&gt;
	q = q:gsub(&amp;#039;^full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	for k,v in pairs(quests) do&lt;br /&gt;
		for i,l in ipairs(v[&amp;#039;quests&amp;#039;]) do&lt;br /&gt;
			local _l = l:gsub(&amp;#039;^Full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^Started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
			_l = _l:lower()&lt;br /&gt;
			&lt;br /&gt;
			if q == _l then&lt;br /&gt;
				table.insert(qs, k)&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if #qs == 0 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(qs, _sortFunc)&lt;br /&gt;
	return qs&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._getQuests(q, getNested)&lt;br /&gt;
	--[=[&lt;br /&gt;
	-- preserves nesting structure&lt;br /&gt;
	-- saving here in case we want it, but not used&lt;br /&gt;
	function nest(_q)&lt;br /&gt;
		local nqs = getQuests(_q)&lt;br /&gt;
		local r = nil&lt;br /&gt;
		if nqs ~= nil then&lt;br /&gt;
			r = nqs&lt;br /&gt;
			for i,v in ipairs(nqs) do&lt;br /&gt;
				table.insert(nqs, nest(v))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return r&lt;br /&gt;
	end&lt;br /&gt;
	--]=]&lt;br /&gt;
	-- does not preserve structure&lt;br /&gt;
	local nestedQuests = {}&lt;br /&gt;
	function nest(_q)&lt;br /&gt;
		local nqs = getQuests(_q)&lt;br /&gt;
		local r = nil&lt;br /&gt;
		if nqs ~= nil then&lt;br /&gt;
			r = nqs&lt;br /&gt;
			for i,v in ipairs(nqs) do&lt;br /&gt;
				if not nestedQuests[v] then&lt;br /&gt;
					nestedQuests[v] = true&lt;br /&gt;
					nest(v)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return r&lt;br /&gt;
	end&lt;br /&gt;
	local qs = getQuests(q)&lt;br /&gt;
	if qs == nil then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if getNested then&lt;br /&gt;
		nest(q)&lt;br /&gt;
		-- unmark the direct requirements&lt;br /&gt;
		for i,v in ipairs(qs) do&lt;br /&gt;
			nestedQuests[v] = nil&lt;br /&gt;
		end&lt;br /&gt;
		local _nested = {}&lt;br /&gt;
		for k,v in pairs(nestedQuests) do&lt;br /&gt;
			-- remove duplicate &amp;#039;Full completion of X/Started X&amp;#039; if X is already listed&lt;br /&gt;
			-- usually applies to early quests that are required a lot&lt;br /&gt;
			-- e.g. Desert Treasure is required for Children of Mah in several ways, some of which are direct requirements&lt;br /&gt;
			-- (Desert Treasure -&amp;gt; The Temple at Senntisten -&amp;gt; The Light Within -&amp;gt; Children of Mah)&lt;br /&gt;
			-- and some are through &amp;#039;Full completion&amp;#039; requirements&lt;br /&gt;
			-- (Desert Treasure -&amp;gt; The Temple at Senntisten -&amp;gt; Ritual of the Mahjarrat -&amp;gt; Koschei&amp;#039;s Troubles -&amp;gt; Full:Children of Mah)&lt;br /&gt;
			-- listing both is confusing so remove full/started requirements if the quest is just normally listed&lt;br /&gt;
			if k:find(&amp;#039;^Full:&amp;#039;) or k:find(&amp;#039;^Started&amp;#039;) then&lt;br /&gt;
				local _k = k:gsub(&amp;#039;^Full:&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^Started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
				if not nestedQuests[_k] then&lt;br /&gt;
					table.insert(_nested, k)&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				table.insert(_nested, k)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		table.sort(_nested, _sortFunc)&lt;br /&gt;
		nestedQuests = _nested&lt;br /&gt;
	else&lt;br /&gt;
		nestedQuests = nil&lt;br /&gt;
	end&lt;br /&gt;
	return qs, nestedQuests&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._quests(args)&lt;br /&gt;
	local q = args[1] or mw.title.getCurrentTitle().text&lt;br /&gt;
	q = string.gsub(q, &amp;quot;/Quick guide&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	if not quests[q] then&lt;br /&gt;
		return string.format(&amp;#039;&amp;quot;%s&amp;quot; is not a recognised quest name.&amp;#039;, q)&lt;br /&gt;
	end&lt;br /&gt;
	local qs, indirqs = p._getQuests(q, not yesno(args.noindirect))&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	if qs == nil or #qs == 0 then&lt;br /&gt;
		table.insert(ret, string.format(&amp;#039;%s is not currently required for any Quests, Miniquests, or Achievement Diaries.&amp;#039;, q))&lt;br /&gt;
	else&lt;br /&gt;
		table.insert(ret, string.format(&amp;#039;%s is directly required for the following Quests, Miniquests, and Achievement Diaries:&amp;#039;, q))&lt;br /&gt;
		for i,v in ipairs(qs) do&lt;br /&gt;
			local repl, str&lt;br /&gt;
			str = &amp;#039;&amp;#039;&lt;br /&gt;
			v, repl = string.gsub(v, &amp;#039;^Full:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
			if repl &amp;gt; 0 then&lt;br /&gt;
				str = &amp;#039;Full completion of &amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			-- doubt this will ever happen but here&amp;#039;s support for it anyway&lt;br /&gt;
			v, repl = string.gsub(v, &amp;#039;^Started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
			if repl &amp;gt; 0 then&lt;br /&gt;
				str = &amp;#039;Starting &amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			table.insert(ret, string.format(&amp;#039;* %s[[%s]]&amp;#039;, str, v))&lt;br /&gt;
		end&lt;br /&gt;
		if indirqs and #indirqs &amp;gt; 0 then&lt;br /&gt;
			table.insert(ret, &amp;#039;&amp;#039;)&lt;br /&gt;
			table.insert(ret, &amp;#039;&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;display:inline-block;&amp;quot;&amp;gt;It is therefore an indirect requirement for the following Quests, Miniquests, and Achievement Diaries:&amp;amp;nbsp;&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&amp;#039;)&lt;br /&gt;
			for i,v in ipairs(indirqs) do&lt;br /&gt;
				local repl, str&lt;br /&gt;
				str = &amp;#039;&amp;#039;&lt;br /&gt;
				v, repl = string.gsub(v, &amp;#039;^Full:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
				if repl &amp;gt; 0 then&lt;br /&gt;
					str = &amp;#039;Full completion of &amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				-- doubt this will ever happen but here&amp;#039;s support for it anyway&lt;br /&gt;
				v, repl = string.gsub(v, &amp;#039;^Started:&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
				if repl &amp;gt; 0 then&lt;br /&gt;
					str = &amp;#039;Starting &amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				table.insert(ret, string.format(&amp;#039;* %s[[%s]]&amp;#039;, str, v))&lt;br /&gt;
			end&lt;br /&gt;
			table.insert(ret, &amp;#039;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	return table.concat(ret, &amp;#039;\n&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.quests(frame)&lt;br /&gt;
	return p._quests(frame:getParent().args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
--&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>