mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-28 03:55:23 +09:00
997 lines
34 KiB
HTML
997 lines
34 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/expcore.commands.html">expcore.commands</a></li>
|
|
<li><strong>expcore.common</strong></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/expcore.permission_groups.html">expcore.permission_groups</a></li>
|
|
<li><a href="../modules/expcore.roles.html">expcore.roles</a></li>
|
|
<li><a href="../modules/expcore.store.html">expcore.store</a></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.common</code></h1>
|
|
<p>Adds some commonly used functions used in many modules</p>
|
|
<p>
|
|
[[</p>
|
|
<h3>Info:</h3>
|
|
<ul>
|
|
<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="#Common.type_check">Common.type_check (value[, test_type=nil])</a></td>
|
|
<td class="summary">Compare types faster for faster validation of params</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.type_check_error">Common.type_check_error (value, test_type, error_message, level)</a></td>
|
|
<td class="summary">Raises an error if the value is of the wrong type</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.param_check">Common.param_check (value, test_type, param_name, param_number)</a></td>
|
|
<td class="summary">Raises an error when the value is the incorrect type, uses a consistent error message format</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.player_return">Common.player_return (value[, 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="#Common.write_json">Common.write_json (path, tbl)</a></td>
|
|
<td class="summary">Writes a table object to a file in json format</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.opt_require">Common.opt_require (path)</a></td>
|
|
<td class="summary">Calls a require that will not error if the file is not found</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.ext_require">Common.ext_require (path, ...)</a></td>
|
|
<td class="summary">Calls a require and returns only the keys given, file must return a table</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.format_time">Common.format_time (ticks, options)</a></td>
|
|
<td class="summary">Formats tick into a clean format, denominations from highest to lowest
|
|
long will use words rather than letters
|
|
time will use : separates
|
|
string will return a string not a locale string
|
|
when a denomination is false it will overflow into the next one</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.move_items">Common.move_items (items[, surface=navies[, position={0[, radius=32[, chest_type=iron-chest]]]])</a></td>
|
|
<td class="summary">Moves items to the position and stores them in the closest entity of the type given</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.print_grid_value">Common.print_grid_value (value, surface, position, scale, offset, immutable)</a></td>
|
|
<td class="summary">https://github.com/Refactorio/RedMew/blob/9184b2940f311d8c9c891e83429fc57ec7e0c4a2/map_gen/maps/diggy/debug.lua#L31
|
|
Prints a colored value on a location.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.print_colored_grid_value">Common.print_colored_grid_value (value, surface, position, offset, immutable, color_value, base_color, delta_color, under_bound, over_bound)</a></td>
|
|
<td class="summary">Prints a colored value on a location.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.clear_flying_text">Common.clear_flying_text (surface)</a></td>
|
|
<td class="summary">Clears all flying text entites on a surface</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.string_contains">Common.string_contains (s, contains)</a></td>
|
|
<td class="summary">Tests if a string contains a given substring.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.extract_keys">Common.extract_keys (tbl, ...)</a></td>
|
|
<td class="summary">Extracts certain keys from a table</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.enum">Common.enum (tbl)</a></td>
|
|
<td class="summary">Converts a table to an enum</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.auto_complete">Common.auto_complete (options, input[, use_key=false[, rtn_key=false]])</a></td>
|
|
<td class="summary">Returns the closest match to the input</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.table_keys">Common.table_keys (tbl)</a></td>
|
|
<td class="summary">Returns all the keys of a table</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.table_values">Common.table_values (tbl)</a></td>
|
|
<td class="summary">Returns all the values of a table</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.table_alphanumsort">Common.table_alphanumsort (tbl)</a></td>
|
|
<td class="summary">Returns the list is a sorted way that would be expected by people (this is by key)</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.table_keysort">Common.table_keysort (tbl)</a></td>
|
|
<td class="summary">Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.format_chat_colour">Common.format_chat_colour (message, color)</a></td>
|
|
<td class="summary">Returns a message with valid chat tags to change its colour</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.format_chat_colour_localized">Common.format_chat_colour_localized (message, color)</a></td>
|
|
<td class="summary">Returns a message with valid chat tags to change its colour, using localization</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#Common.format_chat_player_name">Common.format_chat_player_name (player[, raw_string=false])</a></td>
|
|
<td class="summary">Returns the players name in the players color</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br/>
|
|
<br/>
|
|
|
|
|
|
<h2><a name="Functions"></a>Functions</h2>
|
|
|
|
<dl class="function">
|
|
<dt>
|
|
<a name = "Common.type_check"></a>
|
|
<strong>Common.type_check (value[, test_type=nil])</strong>
|
|
</dt>
|
|
<dd>
|
|
Compare types faster for faster validation of params
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">value</span>
|
|
<span class="types"><span class="type">any</span></span>
|
|
the value to be tested
|
|
</li>
|
|
<li><span class="parameter">test_type</span>
|
|
<span class="types"><a class="type" href="http://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">boolean</span></span>
|
|
is v of type test_type
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<li><pre class="example">type_check(<span class="string">'foo'</span>,<span class="string">'string'</span>) -- <span class="keyword">return</span> <span class="keyword">true</span></pre></li>
|
|
<li><pre class="example">type_check(<span class="string">'foo'</span>) -- <span class="keyword">return</span> <span class="keyword">false</span></pre></li>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.type_check_error"></a>
|
|
<strong>Common.type_check_error (value, test_type, error_message, level)</strong>
|
|
</dt>
|
|
<dd>
|
|
Raises an error if the value is of the wrong type
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">value</span>
|
|
<span class="types"><span class="type">any</span></span>
|
|
the value that you want to test the type of
|
|
</li>
|
|
<li><span class="parameter">test_type</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the type that the value should be
|
|
</li>
|
|
<li><span class="parameter">error_message</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the error message that is returned
|
|
</li>
|
|
<li><span class="parameter">level</span>
|
|
<span class="types"><span class="type">number</span></span>
|
|
the level to call the error on (level = 1 means the caller)
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
true if no error was called
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example">type_check_error(<span class="string">'foo'</span>,<span class="string">'number'</span>,<span class="string">'Value must be a number'</span>) -- will raise error <span class="string">"Value must be a number"</span></pre>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.param_check"></a>
|
|
<strong>Common.param_check (value, test_type, param_name, param_number)</strong>
|
|
</dt>
|
|
<dd>
|
|
Raises an error when the value is the incorrect type, uses a consistent error message format
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">value</span>
|
|
<span class="types"><span class="type">any</span></span>
|
|
the value that you want to test the type of
|
|
</li>
|
|
<li><span class="parameter">test_type</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the type that the value should be
|
|
</li>
|
|
<li><span class="parameter">param_name</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the name of the param
|
|
</li>
|
|
<li><span class="parameter">param_number</span>
|
|
<span class="types"><span class="type">number</span></span>
|
|
the number param it is
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
true if no error was raised
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example">param_check(<span class="string">'foo'</span>,<span class="string">'number'</span>,<span class="string">'repeat_count'</span>,<span class="number">2</span>) -- will raise error <span class="string">"Invalid param #02 given to <anon>; repeat_count is not of type number"</span></pre>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.player_return"></a>
|
|
<strong>Common.player_return (value[, 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">value</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="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the colour of the text for the player, ignored 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>) -- returns <span class="string">'Hello, World!'</span> to game.player <span class="keyword">or</span> server console</pre></li>
|
|
<li><pre class="example">player_return(<span class="string">'Hello, World!'</span>,<span class="string">'green'</span>) -- returns <span class="string">'Hello, World!'</span> to game.player with colour green <span class="keyword">or</span> server console</pre></li>
|
|
<li><pre class="example">player_return(<span class="string">'Hello, World!'</span>,<span class="keyword">nil</span>,player) -- returns <span class="string">'Hello, World!'</span> to the given player</pre></li>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.write_json"></a>
|
|
<strong>Common.write_json (path, tbl)</strong>
|
|
</dt>
|
|
<dd>
|
|
Writes a table object to a file in json format
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">path</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the path of the file to write include / to use dir
|
|
</li>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
the table that will be converted to a json string and wrote to file
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.opt_require"></a>
|
|
<strong>Common.opt_require (path)</strong>
|
|
</dt>
|
|
<dd>
|
|
Calls a require that will not error if the file is not found
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">path</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the path that you want to require
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
the returns from that file or nil, error if not loaded
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example"><span class="keyword">local</span> file = opt_require(<span class="string">'file.not.present'</span>) -- will <span class="keyword">not</span> cause any error</pre>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.ext_require"></a>
|
|
<strong>Common.ext_require (path, ...)</strong>
|
|
</dt>
|
|
<dd>
|
|
Calls a require and returns only the keys given, file must return a table
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">path</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the path that you want to require
|
|
</li>
|
|
<li><span class="parameter">...</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the name of the keys that you want returned
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
the keys in the order given
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example"><span class="keyword">local</span> extract, param_check = ext_require(<span class="string">'expcore.common'</span>,<span class="string">'extract'</span>,<span class="string">'param_check'</span>)</pre>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.format_time"></a>
|
|
<strong>Common.format_time (ticks, options)</strong>
|
|
</dt>
|
|
<dd>
|
|
Formats tick into a clean format, denominations from highest to lowest
|
|
long will use words rather than letters
|
|
time will use : separates
|
|
string will return a string not a locale string
|
|
when a denomination is false it will overflow into the next one
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">ticks</span>
|
|
<span class="types"><span class="type">number</span></span>
|
|
the number of ticks that represents a time
|
|
</li>
|
|
<li><span class="parameter">options</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
table a of options to use for the format
|
|
</li>
|
|
</ul>
|
|
|
|
<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 locale string that can be used
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.move_items"></a>
|
|
<strong>Common.move_items (items[, surface=navies[, position={0[, radius=32[, chest_type=iron-chest]]]])</strong>
|
|
</dt>
|
|
<dd>
|
|
Moves items to the position and stores them in the closest entity of the type given
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">items</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
items which are to be added to the chests, ['name']=count
|
|
</li>
|
|
<li><span class="parameter">surface</span>
|
|
<span class="types"><span class="type">LuaSurface</span></span>
|
|
the surface that the items will be moved to
|
|
(<em>default</em> navies)
|
|
</li>
|
|
<li><span class="parameter">position</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
the position that the items will be moved to {x=100,y=100}
|
|
(<em>default</em> {0)
|
|
</li>
|
|
<li><span class="parameter">radius</span>
|
|
<span class="types"><span class="type">number</span></span>
|
|
the radius in which the items are allowed to be placed
|
|
(<em>default</em> 32)
|
|
</li>
|
|
<li><span class="parameter">chest_type</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the chest type that the items should be moved into
|
|
(<em>default</em> iron-chest)
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.print_grid_value"></a>
|
|
<strong>Common.print_grid_value (value, surface, position, scale, offset, immutable)</strong>
|
|
</dt>
|
|
<dd>
|
|
https://github.com/Refactorio/RedMew/blob/9184b2940f311d8c9c891e83429fc57ec7e0c4a2/map_gen/maps/diggy/debug.lua#L31
|
|
Prints a colored value on a location.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">value</span>
|
|
between -1 and 1
|
|
</li>
|
|
<li><span class="parameter">surface</span>
|
|
LuaSurface
|
|
</li>
|
|
<li><span class="parameter">position</span>
|
|
Position {x, y}
|
|
</li>
|
|
<li><span class="parameter">scale</span>
|
|
float
|
|
</li>
|
|
<li><span class="parameter">offset</span>
|
|
float
|
|
</li>
|
|
<li><span class="parameter">immutable</span>
|
|
bool if immutable, only set, never do a surface lookup, values never change
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.print_colored_grid_value"></a>
|
|
<strong>Common.print_colored_grid_value (value, surface, position, offset, immutable, color_value, base_color, delta_color, under_bound, over_bound)</strong>
|
|
</dt>
|
|
<dd>
|
|
Prints a colored value on a location. When given a color_value and a delta_color,
|
|
will change the color of the text from the base to base + value * delta. This will
|
|
make the color of the text range from 'base_color' to 'base_color + delta_color'
|
|
as the color_value ranges from 0 to 1
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">value</span>
|
|
of number to be displayed
|
|
</li>
|
|
<li><span class="parameter">surface</span>
|
|
LuaSurface
|
|
</li>
|
|
<li><span class="parameter">position</span>
|
|
Position {x, y}
|
|
</li>
|
|
<li><span class="parameter">offset</span>
|
|
float position offset
|
|
</li>
|
|
<li><span class="parameter">immutable</span>
|
|
bool if immutable, only set, never do a surface lookup, values never change
|
|
</li>
|
|
<li><span class="parameter">color_value</span>
|
|
float How far along the range of values of colors the value is to be displayed
|
|
</li>
|
|
<li><span class="parameter">base_color</span>
|
|
{r,g,b} The color for the text to be if color_value is 0
|
|
</li>
|
|
<li><span class="parameter">delta_color</span>
|
|
{r,g,b} The amount to correct the base_color if color_value is 1
|
|
</li>
|
|
<li><span class="parameter">under_bound</span>
|
|
{r,g,b} The color to be used if color_value < 0
|
|
</li>
|
|
<li><span class="parameter">over_bound</span>
|
|
{r,g,b} The color to be used if color_value > 1
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.clear_flying_text"></a>
|
|
<strong>Common.clear_flying_text (surface)</strong>
|
|
</dt>
|
|
<dd>
|
|
Clears all flying text entites on a surface
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">surface</span>
|
|
<span class="types"><span class="type">LuaSurface</span></span>
|
|
the surface to clear
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.string_contains"></a>
|
|
<strong>Common.string_contains (s, contains)</strong>
|
|
</dt>
|
|
<dd>
|
|
Tests if a string contains a given substring.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">s</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the string to check for the substring
|
|
</li>
|
|
<li><span class="parameter">contains</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the substring to test for
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
true if the substring was found in the string
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.extract_keys"></a>
|
|
<strong>Common.extract_keys (tbl, ...)</strong>
|
|
</dt>
|
|
<dd>
|
|
Extracts certain keys from a table
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
table the which contains the keys
|
|
</li>
|
|
<li><span class="parameter">...</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the names of the keys you want extracted
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
the keys in the order given
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example"><span class="keyword">local</span> key_three, key_one = extract({key_one=<span class="string">'foo'</span>,key_two=<span class="string">'bar'</span>,key_three=<span class="keyword">true</span>},<span class="string">'key_three'</span>,<span class="string">'key_one'</span>)</pre>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.enum"></a>
|
|
<strong>Common.enum (tbl)</strong>
|
|
</dt>
|
|
<dd>
|
|
Converts a table to an enum
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
table the that will be converted
|
|
</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>
|
|
the new table that acts like an enum
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.auto_complete"></a>
|
|
<strong>Common.auto_complete (options, input[, use_key=false[, rtn_key=false]])</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns the closest match to the input
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">options</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
table a of options for the auto complete
|
|
</li>
|
|
<li><span class="parameter">input</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
string the input that will be completed
|
|
</li>
|
|
<li><span class="parameter">use_key</span>
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
when true the keys of options will be used as the options
|
|
(<em>default</em> false)
|
|
</li>
|
|
<li><span class="parameter">rtn_key</span>
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
when true the the key will be returned rather than the value
|
|
(<em>default</em> false)
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
the list item found that matches the input
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.table_keys"></a>
|
|
<strong>Common.table_keys (tbl)</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns all the keys of a table
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
table the to get the keys 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>
|
|
an array of the table keys
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.table_values"></a>
|
|
<strong>Common.table_values (tbl)</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns all the values of a table
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
table the to get the values 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>
|
|
an array of the table values
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.table_alphanumsort"></a>
|
|
<strong>Common.table_alphanumsort (tbl)</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns the list is a sorted way that would be expected by people (this is by key)
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
the table to be sorted
|
|
</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>
|
|
the sorted table
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.table_keysort"></a>
|
|
<strong>Common.table_keysort (tbl)</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">tbl</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
the table to be sorted
|
|
</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>
|
|
the sorted table
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.format_chat_colour"></a>
|
|
<strong>Common.format_chat_colour (message, color)</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns a message with valid chat tags to change its colour
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">message</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
|
|
the message that will be in the output
|
|
</li>
|
|
<li><span class="parameter">color</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
a color which contains r,g,b as its keys
|
|
</li>
|
|
</ul>
|
|
|
|
<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>
|
|
the message with the color tags included
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.format_chat_colour_localized"></a>
|
|
<strong>Common.format_chat_colour_localized (message, color)</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns a message with valid chat tags to change its colour, using localization
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">message</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a> or <a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
the message that will be in the output
|
|
</li>
|
|
<li><span class="parameter">color</span>
|
|
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
|
|
a color which contains r,g,b as its keys
|
|
</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>
|
|
the message with the color tags included
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "Common.format_chat_player_name"></a>
|
|
<strong>Common.format_chat_player_name (player[, raw_string=false])</strong>
|
|
</dt>
|
|
<dd>
|
|
Returns the players name in the players color
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">player</span>
|
|
<span class="types"><span class="type">LuaPlayer</span></span>
|
|
the player to use the name and color of
|
|
</li>
|
|
<li><span class="parameter">raw_string</span>
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
when true a is returned rather than a localized string
|
|
(<em>default</em> false)
|
|
</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>
|
|
the players name with tags for the players color
|
|
</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:30:49 </i>
|
|
</div> <!-- id="about" -->
|
|
</div> <!-- id="container" -->
|
|
</body>
|
|
</html>
|