Files
factorio-scenario-ExpCluster/doc/modules/expcore.store.html
2019-05-29 22:28:53 +01:00

465 lines
17 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Reference</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>ldoc</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../modules/config._file_loader.html">config._file_loader</a></li>
<li><a href="../modules/config.action_buttons.html">config.action_buttons</a></li>
<li><a href="../modules/config.advanced_start.html">config.advanced_start</a></li>
<li><a href="../modules/config.death_logger.html">config.death_logger</a></li>
<li><a href="../modules/config.expcore-commands.auth_admin.html">config.expcore-commands.auth_admin</a></li>
<li><a href="../modules/config.expcore-commands.auth_roles.html">config.expcore-commands.auth_roles</a></li>
<li><a href="../modules/config.expcore-commands.auth_runtime_disable.html">config.expcore-commands.auth_runtime_disable</a></li>
<li><a href="../modules/config.expcore-commands.parse_general.html">config.expcore-commands.parse_general</a></li>
<li><a href="../modules/config.expcore-commands.parse_roles.html">config.expcore-commands.parse_roles</a></li>
<li><a href="../modules/config.permission_groups.html">config.permission_groups</a></li>
<li><a href="../modules/config.popup_messages.html">config.popup_messages</a></li>
<li><a href="../modules/config.rockets.html">config.rockets</a></li>
<li><a href="../modules/config.roles.html">config.roles</a></li>
<li><a href="../modules/config.scorched_earth.html">config.scorched_earth</a></li>
<li><a href="../modules/config.spawn_area.html">config.spawn_area</a></li>
<li><a href="../modules/config.warnings.html">config.warnings</a></li>
<li><a href="../modules/control.html">control</a></li>
<li><a href="../modules/Commands.html">Commands</a></li>
<li><a href="../modules/Common.html">Common</a></li>
<li><a href="../modules/expcore.gui.html">expcore.gui</a></li>
<li><a href="../modules/expcore.gui.buttons.html">expcore.gui.buttons</a></li>
<li><a href="../modules/expcore.gui.center.html">expcore.gui.center</a></li>
<li><a href="../modules/expcore.gui.checkboxs.html">expcore.gui.checkboxs</a></li>
<li><a href="../modules/expcore.gui.core.html">expcore.gui.core</a></li>
<li><a href="../modules/expcore.gui.dropdown.html">expcore.gui.dropdown</a></li>
<li><a href="../modules/expcore.gui.elem-button.html">expcore.gui.elem-button</a></li>
<li><a href="../modules/expcore.gui.instances.html">expcore.gui.instances</a></li>
<li><a href="../modules/expcore.gui.left.html">expcore.gui.left</a></li>
<li><a href="../modules/expcore.gui.popups.html">expcore.gui.popups</a></li>
<li><a href="../modules/expcore.gui.progress-bar.html">expcore.gui.progress-bar</a></li>
<li><a href="../modules/expcore.gui.slider.html">expcore.gui.slider</a></li>
<li><a href="../modules/expcore.gui.test.html">expcore.gui.test</a></li>
<li><a href="../modules/expcore.gui.text.html">expcore.gui.text</a></li>
<li><a href="../modules/expcore.gui.toolbar.html">expcore.gui.toolbar</a></li>
<li><a href="../modules/Permissions_Groups.html">Permissions_Groups</a></li>
<li><a href="../modules/Commands.html">Commands</a></li>
<li><strong>expcore.store</strong></li>
<li><a href="../modules/modules.addons.advanced-start.html">modules.addons.advanced-start</a></li>
<li><a href="../modules/modules.addons.chat-popups.html">modules.addons.chat-popups</a></li>
<li><a href="../modules/modules.addons.damage-popups.html">modules.addons.damage-popups</a></li>
<li><a href="../modules/modules.gui.player-list.html">modules.gui.player-list</a></li>
<li><a href="../modules/modules.gui.rocket-info.html">modules.gui.rocket-info</a></li>
<li><a href="../modules/modules.gui.science-info.html">modules.gui.science-info</a></li>
<li><a href="../modules/modules.gui.task-list.html">modules.gui.task-list</a></li>
<li><a href="../modules/utils.alien_evolution_progress.html">utils.alien_evolution_progress</a></li>
<li><a href="../modules/utils.core.html">utils.core</a></li>
<li><a href="../modules/utils.debug.html">utils.debug</a></li>
<li><a href="../modules/utils.event.html">utils.event</a></li>
<li><a href="../modules/utils.event_core.html">utils.event_core</a></li>
<li><a href="../modules/utils.math.html">utils.math</a></li>
<li><a href="../modules/utils.recipe_locker.html">utils.recipe_locker</a></li>
<li><a href="../modules/utils.state_machine.html">utils.state_machine</a></li>
<li><a href="../modules/utils.table.html">utils.table</a></li>
<li><a href="../modules/utils.task.html">utils.task</a></li>
<li><a href="../modules/utils.timestamp.html">utils.timestamp</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>expcore.store</code></h1>
<p>Adds an easy way to store and watch for updates to a value
[[</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Store.is_registered">Store.is_registered (location)</a></td>
<td class="summary">Check for if a lcoation is registered</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.uid_location">Store.uid_location ()</a></td>
<td class="summary">Returns a unqiue name that can be used for a store</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.register">Store.register (location, callback[, start_value])</a></td>
<td class="summary">Registers a new location with an update callback which is triggered when the value updates</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.register_synced">Store.register_synced (location, callback[, start_value])</a></td>
<td class="summary">Registers a new cross server synced location with an update callback, and external script is required for cross server</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.add_watch">Store.add_watch (location, callback)</a></td>
<td class="summary">Adds a function that will be checked every tick for a change in the returned value, when the value changes it will be saved in the store</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.get">Store.get (location[, no_error=false])</a></td>
<td class="summary">Gets the value stored at a location, this location must be registered</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.set">Store.set (location, value)</a></td>
<td class="summary">Sets the value at a location, this location must be registered, if server synced it will emit the change to file</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.get_children">Store.get_children (location)</a></td>
<td class="summary">Gets all non nil children at a location, children can be added and removed during runtime
this is similar to Store.get but will always return a table even if it is empty</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.get_child">Store.get_child (location, child)</a></td>
<td class="summary">Gets the value of the child to a location, children can be added and removed during runtime</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Store.set_child">Store.set_child (location, child, value)</a></td>
<td class="summary">Sets the value of the chlid to a location, children can be added and removed during runtime
when a child is set it will call the update handler of the parent allowing children be to added at runtime
this may be used when a player joins the game and the child is the players name</td>
</tr>
</table>
<br/>
<br/>
<h2><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "Store.is_registered"></a>
<strong>Store.is_registered (location)</strong>
</dt>
<dd>
Check for if a lcoation is registered
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location to test for
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if registered
</ol>
</dd>
<dt>
<a name = "Store.uid_location"></a>
<strong>Store.uid_location ()</strong>
</dt>
<dd>
Returns a unqiue name that can be used for a store
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
a unqiue name
</ol>
</dd>
<dt>
<a name = "Store.register"></a>
<strong>Store.register (location, callback[, start_value])</strong>
</dt>
<dd>
Registers a new location with an update callback which is triggered when the value updates
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
string a unique that points to the data, string used rather than token to allow migration
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
this callback will be called when the stored value is set to a new value
</li>
<li><span class="parameter">start_value</span>
<span class="types"><span class="type">any</span></span>
this value will be the inital value that is stored at this location
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Store.register_synced"></a>
<strong>Store.register_synced (location, callback[, start_value])</strong>
</dt>
<dd>
Registers a new cross server synced location with an update callback, and external script is required for cross server
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
string a unique that points to the data, string used rather than token to allow migration
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
this callback will be called when the stored value is set to a new value
</li>
<li><span class="parameter">start_value</span>
<span class="types"><span class="type">any</span></span>
this value will be the inital value that is stored at this location
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Store.add_watch"></a>
<strong>Store.add_watch (location, callback)</strong>
</dt>
<dd>
Adds a function that will be checked every tick for a change in the returned value, when the value changes it will be saved in the store
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location where the data will be saved and compeared to, must already be a registered location
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
this function will be called every tick to check for a change in value
</li>
</ul>
</dd>
<dt>
<a name = "Store.get"></a>
<strong>Store.get (location[, no_error=false])</strong>
</dt>
<dd>
Gets the value stored at a location, this location must be registered
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location to get the data from
</li>
<li><span class="parameter">no_error</span>
<span class="types"><span class="type">boolean</span></span>
when true no error is returned if the location is not registered
(<em>default</em> false)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">any</span></span>
the data which was stored at the location
</ol>
</dd>
<dt>
<a name = "Store.set"></a>
<strong>Store.set (location, value)</strong>
</dt>
<dd>
Sets the value at a location, this location must be registered, if server synced it will emit the change to file
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location to set the data to
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">any</span></span>
the new value to set at the location, value may be reverted if there is a watch callback
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if it was successful
</ol>
</dd>
<dt>
<a name = "Store.get_children"></a>
<strong>Store.get_children (location)</strong>
</dt>
<dd>
Gets all non nil children at a location, children can be added and removed during runtime
this is similar to Store.get but will always return a table even if it is empty
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location to get the children of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
a table containg all the children and they values
</ol>
</dd>
<dt>
<a name = "Store.get_child"></a>
<strong>Store.get_child (location, child)</strong>
</dt>
<dd>
Gets the value of the child to a location, children can be added and removed during runtime
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location of which the child is located
</li>
<li><span class="parameter">child</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the child element to get the value of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">any</span></span>
the value which was stored at that location
</ol>
</dd>
<dt>
<a name = "Store.set_child"></a>
<strong>Store.set_child (location, child, value)</strong>
</dt>
<dd>
Sets the value of the chlid to a location, children can be added and removed during runtime
when a child is set it will call the update handler of the parent allowing children be to added at runtime
this may be used when a player joins the game and the child is the players name
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">location</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the location of which the child is located
</li>
<li><span class="parameter">child</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the child element to set the value of
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">any</span></span>
the value to set at this location
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if it was successful
</ol>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2019-05-29 22:26:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>