<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3AModuleAddSavedVariable</id>
	<title>API:ModuleAddSavedVariable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3AModuleAddSavedVariable"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:ModuleAddSavedVariable&amp;action=history"/>
	<updated>2026-10-17T22:06:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:ModuleAddSavedVariable&amp;diff=30605&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:ModuleAddSavedVariable&amp;diff=30605&amp;oldid=prev"/>
		<updated>2026-10-16T19:47:14Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Module}}&lt;br /&gt;
Adds a saved variable to a UI module at run time, as if it were listed in the module&amp;#039;s &amp;lt;code&amp;gt;.mod&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ModuleAddSavedVariable(moduleName, variableName, flag)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;moduleName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – The module&amp;#039;s name, as in the &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; field of [[API:ModulesGetData|ModulesGetData]].&lt;br /&gt;
;variableName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Name of the Lua variable to save, for example &amp;lt;code&amp;gt;&amp;quot;MyAddon.Settings&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
;flag : &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; – Selects which of the module&amp;#039;s two saved-variable lists the name is added to. See [[#Details|Details]].&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Nothing.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* A module keeps two lists of saved variables. &amp;lt;code&amp;gt;flag = false&amp;lt;/code&amp;gt; adds the name to the first list, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; to the second. The name is refused if it is already in either list. The client also uses this routine for the &amp;lt;code&amp;gt;&amp;amp;lt;SavedVariable&amp;amp;gt;&amp;lt;/code&amp;gt; names of the &amp;lt;code&amp;gt;.mod&amp;lt;/code&amp;gt; file. Which list is saved where could not be confirmed.&lt;br /&gt;
* The change is accepted only while the module is initialized or being initialized (from the moment its initialization starts). For a module that has not started initializing, the &amp;#039;&amp;#039;is not loaded&amp;#039;&amp;#039; error is logged. Its wording (&amp;quot;You may not modify the SavedVariables on a Module that is initialized&amp;quot;) is the opposite of what the check does.&lt;br /&gt;
* &amp;lt;code&amp;gt;flag&amp;lt;/code&amp;gt; must be a real boolean. Passing &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; or a number raises an &amp;#039;&amp;#039;Invalid Parameters&amp;#039;&amp;#039; error.&lt;br /&gt;
* The function needs at least three arguments and only reads the last three.&lt;br /&gt;
* The stock UI never calls &amp;lt;code&amp;gt;ModuleAddSavedVariable&amp;lt;/code&amp;gt;; stock modules list their saved variables in their &amp;lt;code&amp;gt;.mod&amp;lt;/code&amp;gt; files.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
These are written to the UI log; the call returns normally.&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;ModuleAddSavedVariable&amp;#039;: %s is not a valid UiMod name.&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;ModuleAddSavedVariable&amp;#039;: %s is not loaded. You may not modify the SavedVariables on a Module that is initialized.&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;ModuleAddSavedVariable&amp;#039;: %s already has &amp;#039;%s&amp;#039; registered as a saved variable.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
A minimal example built from the signature above:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ModuleAddSavedVariable( &amp;quot;MyAddon&amp;quot;, &amp;quot;MyAddon.Settings&amp;quot;, false )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:ModuleRemoveSavedVariable|ModuleRemoveSavedVariable]]&lt;br /&gt;
* [[API:ModulesSaveSettings|ModulesSaveSettings]]&lt;br /&gt;
* [[API:ModulesGetData|ModulesGetData]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>