Files
factorio-scenario-ExpCluster/doc/modules/ExpGamingLib.html
Cooldude2606 4d05f13cb3 Updated Doc
2018-06-01 16:30:32 +01:00

420 lines
13 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="nowrap">
<li><a href="../modules/FSM.html">FSM</a></li>
<li><a href="../modules/modules.expgamingcore.commands.control.html">modules.expgamingcore.commands.control</a></li>
<li><a href="../modules/modules.expgamingcore.gui.guiparts.center.html">modules.expgamingcore.gui.guiparts.center</a></li>
<li><a href="../modules/modules.expgamingcore.gui.guiparts.inputs.html">modules.expgamingcore.gui.guiparts.inputs</a></li>
<li><a href="../modules/modules.expgamingcore.gui.guiparts.left.html">modules.expgamingcore.gui.guiparts.left</a></li>
<li><a href="../modules/modules.expgamingcore.gui.guiparts.popup.html">modules.expgamingcore.gui.guiparts.popup</a></li>
<li><a href="../modules/modules.expgamingcore.gui.guiparts.toolbar.html">modules.expgamingcore.gui.guiparts.toolbar</a></li>
<li><a href="../modules/modules.expgamingcore.gui.control.html">modules.expgamingcore.gui.control</a></li>
<li><a href="../modules/modules.expgamingcore.ranking.control.html">modules.expgamingcore.ranking.control</a></li>
<li><a href="../modules/ExpGamingCore.Server.html">ExpGamingCore.Server</a></li>
<li><a href="../modules/ExpGamingCore.Sync.html">ExpGamingCore.Sync</a></li>
<li><strong>ExpGamingLib</strong></li>
<li><a href="../modules/StdLib.Color.html">StdLib.Color</a></li>
<li><a href="../modules/StdLib.Game.html">StdLib.Game</a></li>
<li><a href="../modules/StdLib.String.html">StdLib.String</a></li>
<li><a href="../modules/StdLib.Table.html">StdLib.Table</a></li>
<li><a href="../modules/StdLib.Time.html">StdLib.Time</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>ExpGamingLib</code></h1>
<p>Adds some common functions used though out all ExpGaming modules</p>
<p></p>
<h3>Info:</h3>
<ul>
<li><strong>License</strong>: https://github.com/explosivegaming/scenario/blob/master/LICENSE</li>
<li><strong>Author</strong>: Cooldude2606</li>
</ul>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#unpack_to_G">unpack_to_G (tbl)</a></td>
<td class="summary">Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_env">get_env ()</a></td>
<td class="summary">Used to get the current ENV with all _G keys removed; useful when saving function to global</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add_metatable">add_metatable (tbl[, callback=tostring[, string=table.tostring]])</a></td>
<td class="summary">Creats a table that will act like a string and a function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_type">is_type (v[, test_type=nil])</a></td>
<td class="summary">Compear types faster for faster valadation of prams</td>
</tr>
<tr>
<td class="name" nowrap><a href="#player_return">player_return (rtn[, colour=defines.colour.white[, player=game.player]])</a></td>
<td class="summary">Will return a value of any type to the player/server console, allows colour for in-game players</td>
</tr>
<tr>
<td class="name" nowrap><a href="#tick_to_hour">tick_to_hour (tick)</a></td>
<td class="summary">Convert ticks to hours</td>
</tr>
<tr>
<td class="name" nowrap><a href="#tick_to_min">tick_to_min (tick)</a></td>
<td class="summary">Convert ticks to minutes</td>
</tr>
<tr>
<td class="name" nowrap><a href="#tick_to_display_format">tick_to_display_format (tick)</a></td>
<td class="summary">Converts a tick into a clean format for end user</td>
</tr>
<tr>
<td class="name" nowrap><a href="#gui_tree">gui_tree (root)</a></td>
<td class="summary">Used as a way to view the structure of a gui, used for debuging</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "unpack_to_G"></a>
<strong>unpack_to_G (tbl)</strong>
</dt>
<dd>
Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tbl</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
table to be unpacked
</li>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">unpack_to_G{key1=<span class="string">'foo'</span>,key2=<span class="string">'bar'</span>}</pre>
</ul>
</dd>
<dt>
<a name = "get_env"></a>
<strong>get_env ()</strong>
</dt>
<dd>
Used to get the current ENV with all _G keys removed; useful when saving function to global
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
the env table with _G keys removed
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">get_env() returns current ENV with _G keys removed</pre>
</ul>
</dd>
<dt>
<a name = "add_metatable"></a>
<strong>add_metatable (tbl[, callback=tostring[, string=table.tostring]])</strong>
</dt>
<dd>
Creats a table that will act like a string and a function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tbl</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
the table that will have its metatable set
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
the function that will be used for the call
(<em>default</em> tostring)
</li>
<li><span class="parameter">string</span>
<span class="types"><span class="type">function</span> or <a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
a function that resolves to a string or a string
(<em>default</em> table.tostring)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
the new table with its metatable set
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">add_metatable({},<span class="keyword">function</span>) <span class="comment">-- returns table</span></pre>
</ul>
</dd>
<dt>
<a name = "is_type"></a>
<strong>is_type (v[, test_type=nil])</strong>
</dt>
<dd>
Compear types faster for faster valadation of prams
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">v</span>
the value to be tested
</li>
<li><span class="parameter">test_type</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the type to test for if not given then it tests for nil
(<em>default</em> nil)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bolean</span></span>
is v of type test_type
</ol>
<h3>Usage:</h3>
<ul>
<li><pre class="example">is_type(<span class="string">'foo'</span>,<span class="string">'string'</span>) <span class="comment">-- return true</span></pre></li>
<li><pre class="example">is_type(<span class="string">'foo'</span>) <span class="comment">-- return false</span></pre></li>
</ul>
</dd>
<dt>
<a name = "player_return"></a>
<strong>player_return (rtn[, colour=defines.colour.white[, player=game.player]])</strong>
</dt>
<dd>
Will return a value of any type to the player/server console, allows colour for in-game players
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rtn</span>
any value of any type that will be returned to the player or console
</li>
<li><span class="parameter">colour</span>
<span class="types"><span class="type">defines.color</span> or <a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the colour of the text for the player, ingroned when printing to console
(<em>default</em> defines.colour.white)
</li>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player that return will go to, if no game.player then returns to server
(<em>default</em> game.player)
</li>
</ul>
<h3>Usage:</h3>
<ul>
<li><pre class="example">player_return(<span class="string">'Hello, World!'</span>) <span class="comment">-- returns 'Hello, World!' to game.player or server console</span></pre></li>
<li><pre class="example">player_return(<span class="string">'Hello, World!'</span>,<span class="string">'green'</span>) <span class="comment">-- returns 'Hello, World!' to game.player with colour green or server console</span></pre></li>
<li><pre class="example">player_return(<span class="string">'Hello, World!'</span>,<span class="keyword">nil</span>,player) <span class="comment">-- returns 'Hello, World!' to the given player</span></pre></li>
</ul>
</dd>
<dt>
<a name = "tick_to_hour"></a>
<strong>tick_to_hour (tick)</strong>
</dt>
<dd>
Convert ticks to hours
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tick</span>
<span class="types"><span class="type">number</span></span>
tick to convert to hours
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
the number of whole hours from this tick
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">tick_to_hour(<span class="number">216001</span>) <span class="comment">-- return 1</span></pre>
</ul>
</dd>
<dt>
<a name = "tick_to_min"></a>
<strong>tick_to_min (tick)</strong>
</dt>
<dd>
Convert ticks to minutes
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tick</span>
<span class="types"><span class="type">number</span></span>
tick to convert to minutes
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
the number of whole minutes from this tick
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">tick_to_hour(<span class="number">3601</span>) <span class="comment">-- return 1</span></pre>
</ul>
</dd>
<dt>
<a name = "tick_to_display_format"></a>
<strong>tick_to_display_format (tick)</strong>
</dt>
<dd>
Converts a tick into a clean format for end user
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tick</span>
<span class="types"><span class="type">number</span></span>
the tick to convert
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the formated string
</ol>
<h3>Usage:</h3>
<ul>
<li><pre class="example">tick_to_display_format(<span class="number">3600</span>) <span class="comment">-- return '1.00 M'</span></pre></li>
<li><pre class="example">tick_to_display_format(<span class="number">234000</span>) <span class="comment">-- return '1 H 5 M'</span></pre></li>
</ul>
</dd>
<dt>
<a name = "gui_tree"></a>
<strong>gui_tree (root)</strong>
</dt>
<dd>
Used as a way to view the structure of a gui, used for debuging
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">root</span>
<span class="types"><span class="type">LuaGuiElement</span></span>
the root to start the tree from
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
the table that describes the gui
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">Gui_tree(root) returns all children of gui recusivly</pre>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-06-01 16:29:39 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>