<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://petitplanet.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AConfig</id>
	<title>Module:Config - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://petitplanet.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AConfig"/>
	<link rel="alternate" type="text/html" href="https://petitplanet.wiki/index.php?title=Module:Config&amp;action=history"/>
	<updated>2026-04-08T09:34:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://petitplanet.wiki/index.php?title=Module:Config&amp;diff=11&amp;oldid=prev</id>
		<title>Stevium: Created Module:Config</title>
		<link rel="alternate" type="text/html" href="https://petitplanet.wiki/index.php?title=Module:Config&amp;diff=11&amp;oldid=prev"/>
		<updated>2025-11-09T08:23:26Z</updated>

		<summary type="html">&lt;p&gt;Created Module:Config&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- &amp;lt;pre&amp;gt;&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Source: https://genshin-impact.fandom.com/wiki/Module:Config&lt;br /&gt;
-- Allows wikis to locally override `/config` subpages of modules.&lt;br /&gt;
--&lt;br /&gt;
-- @script config&lt;br /&gt;
-- @alias p&lt;br /&gt;
-- @release experimental&lt;br /&gt;
-- @require [[Module:No globals]]&lt;br /&gt;
-- @require [[Module:TableTools]]&lt;br /&gt;
-- @author [[User:ExE Boss]]&lt;br /&gt;
-- @see [[Module:I18n]] - Inspired the way in which the @{Config} class works.&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local libraryUtil = require(&amp;#039;libraryUtil&amp;#039;);&lt;br /&gt;
local checkType = libraryUtil.checkType;&lt;br /&gt;
local checkTypeMulti = libraryUtil.checkTypeMulti;&lt;br /&gt;
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg;&lt;br /&gt;
&lt;br /&gt;
local tableTools = require(&amp;#039;Module:TableTools&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local p = {};&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- @function p._substArgsInMsg&lt;br /&gt;
-- @param {string} msg&lt;br /&gt;
-- @param {table} args&lt;br /&gt;
--]]&lt;br /&gt;
local function substArgsInMsg(msg, args)&lt;br /&gt;
	checkType(&amp;#039;substArgsInMsg&amp;#039;, 1, msg, &amp;#039;string&amp;#039;);&lt;br /&gt;
	checkType(&amp;#039;substArgsInMsg&amp;#039;, 2, args, &amp;#039;table&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
	for i, value in tableTools.sparseIpairs(args) do&lt;br /&gt;
		msg = string.gsub(msg, &amp;#039;%$&amp;#039; .. tostring(i), tostring(value));&lt;br /&gt;
	end&lt;br /&gt;
	return msg;&lt;br /&gt;
end&lt;br /&gt;
p._substArgsInMsg = substArgsInMsg;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- Configuration datastore class&lt;br /&gt;
-- @type Config&lt;br /&gt;
--]]&lt;br /&gt;
local Config = {};&lt;br /&gt;
Config.__index = Config;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- Datastore option getter.&lt;br /&gt;
--&lt;br /&gt;
-- This method returns values from the datastore corresponding to a `key`.&lt;br /&gt;
--&lt;br /&gt;
-- If the value is a string, then these values may have `$n` parameters, which&lt;br /&gt;
-- can be replaced by optional argument strings supplied by the `getValue` call.&lt;br /&gt;
--&lt;br /&gt;
-- @function Config:getValue&lt;br /&gt;
-- @param {string|table} option Config query or string key to return from the datastore.&lt;br /&gt;
-- @param {string} option.key String key to return from the datastore.&lt;br /&gt;
-- @param[opt] {table} option.args Arguments to substitute into the value (`$n`).&lt;br /&gt;
-- @param[opt] {string} ... Arguments to substitute into the value (`$n`).&lt;br /&gt;
-- @return {nil|boolean|string|number|table}&lt;br /&gt;
--]]&lt;br /&gt;
function Config:getValue(option, ...)&lt;br /&gt;
	checkTypeMulti(&amp;#039;Config:getValue&amp;#039;, 1, option, { &amp;#039;table&amp;#039;, &amp;#039;string&amp;#039; });&lt;br /&gt;
&lt;br /&gt;
	local key;&lt;br /&gt;
	local args;&lt;br /&gt;
&lt;br /&gt;
	if (type(option) == &amp;#039;table&amp;#039;) then&lt;br /&gt;
		key = option.key;&lt;br /&gt;
		checkTypeForNamedArg(&amp;#039;Config:getValue&amp;#039;, &amp;#039;key&amp;#039;, key, &amp;#039;string&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
		args = option.args;&lt;br /&gt;
		checkTypeForNamedArg(&amp;#039;Config:getValue&amp;#039;, &amp;#039;args&amp;#039;, args, &amp;#039;table&amp;#039;, true);&lt;br /&gt;
	else -- type(option) == &amp;#039;string&amp;#039;&lt;br /&gt;
		key = option;&lt;br /&gt;
		args = select(&amp;#039;#&amp;#039;, ...) &amp;gt; 0 and { ... } or nil;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- value fetching&lt;br /&gt;
	local value;&lt;br /&gt;
	for _, data in ipairs(self._data) do&lt;br /&gt;
		value = data[key];&lt;br /&gt;
		if (value ~= nil) then&lt;br /&gt;
			break;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (type(value) == &amp;#039;string&amp;#039; and args) then&lt;br /&gt;
		value = substArgsInMsg(value, args);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return value;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- Loads the configuration from the global `&amp;quot;Dev:&amp;quot; .. source .. &amp;quot;/config&amp;quot;` configuration page&lt;br /&gt;
-- with overrides from the local `&amp;quot;Module:&amp;quot; .. source .. &amp;quot;/config&amp;quot;` configuration page.&lt;br /&gt;
--&lt;br /&gt;
-- @function p.loadConfig&lt;br /&gt;
-- @param {string} source&lt;br /&gt;
-- @return {Config}&lt;br /&gt;
--]]&lt;br /&gt;
function p.loadConfig(source)&lt;br /&gt;
	if (source == &amp;#039;&amp;#039;) then&lt;br /&gt;
		source = nil&lt;br /&gt;
	end&lt;br /&gt;
	checkType(&amp;#039;loadConfig&amp;#039;, 1, source, &amp;#039;string&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
	local cfg = {};&lt;br /&gt;
	cfg._data = {};&lt;br /&gt;
	setmetatable(cfg, Config);&lt;br /&gt;
	&lt;br /&gt;
	source = string.gsub(source, &amp;#039;^.&amp;#039;, mw.ustring.upper);&lt;br /&gt;
	local hasNS = mw.ustring.find(source, &amp;#039;:&amp;#039;);&lt;br /&gt;
    if (not hasNS) then&lt;br /&gt;
        source = &amp;#039;Module:&amp;#039; .. source .. &amp;#039;/config&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
	cfg._data[#cfg._data + 1] = mw.loadData(source);&lt;br /&gt;
	return cfg;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- Exports classes for testing&lt;br /&gt;
--&lt;br /&gt;
-- @function p._exportClasses&lt;br /&gt;
-- @private&lt;br /&gt;
-- @return {table}&lt;br /&gt;
--]]&lt;br /&gt;
function p._exportClasses()&lt;br /&gt;
	return {&lt;br /&gt;
		Config = Config,&lt;br /&gt;
	};&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p;&lt;br /&gt;
-- &amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stevium</name></author>
	</entry>
</feed>