Files
factorio-scenario-ExpCluster/doc/modules/expcore.roles.html
2019-05-29 22:31:23 +01:00

1308 lines
42 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><a href="../modules/expcore.common.html">expcore.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/expcore.permission_groups.html">expcore.permission_groups</a></li>
<li><strong>expcore.roles</strong></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.roles</code></h1>
<p>Factorio role system to manage custom permissions</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="#Roles.debug">Roles.debug ()</a></td>
<td class="summary">Returns a string which contains all roles in index order displaying all data for them</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.print_to_roles">Roles.print_to_roles (roles, message)</a></td>
<td class="summary">Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.print_to_roles_higher">Roles.print_to_roles_higher (role, message)</a></td>
<td class="summary">Prints a message to all players who have the given role or one which is higher (excluding default)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.print_to_roles_lower">Roles.print_to_roles_lower (role, message)</a></td>
<td class="summary">Prints a message to all players who have the given role or one which is lower (excluding default)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.get_role_by_name">Roles.get_role_by_name (name)</a></td>
<td class="summary">Get a role for the given name</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.get_role_by_order">Roles.get_role_by_order (index)</a></td>
<td class="summary">Get a role with the given order index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.get_role_from_any">Roles.get_role_from_any (any)</a></td>
<td class="summary">Gets a role from a name,index or role object (where it is just returned)
nb: this function is used for the input for most outward facing functions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.get_player_roles">Roles.get_player_roles (player)</a></td>
<td class="summary">Gets all the roles of the given player, this will always contain the default role</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.get_player_highest_role">Roles.get_player_highest_role (player)</a></td>
<td class="summary">Gets the highest role which the player has, can be used to compeer one player to another</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.assign_player">Roles.assign_player (player, roles[, by_player_name=<server>[, silent=false]])</a></td>
<td class="summary">Gives a player the given role(s) with an option to pass a by player name used in the log</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.unassign_player">Roles.unassign_player (player, roles[, by_player_name=<server>[, silent=false]])</a></td>
<td class="summary">Removes a player from the given role(s) with an option to pass a by player name used in the log</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.override_player_roles">Roles.override_player_roles (roles)</a></td>
<td class="summary">Overrides all player roles with the given table of roles, useful to mass set roles on game start</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.player_has_role">Roles.player_has_role (player, search_role)</a></td>
<td class="summary">A test for weather a player has the given role</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.player_has_flag">Roles.player_has_flag (player, flag_name)</a></td>
<td class="summary">A test for weather a player has the given flag true for at least one of they roles</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.player_allowed">Roles.player_allowed (player, action)</a></td>
<td class="summary">A test for weather a player has at least one role which is allowed the given action</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.define_role_order">Roles.define_role_order (order)</a></td>
<td class="summary">Used to set the role order, higher in the list is better, must be called at least once in config
nb: function also re links parents due to expected position in the config file</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.define_flag_trigger">Roles.define_flag_trigger (name, callback)</a></td>
<td class="summary">Defines a new trigger for when a tag is added or removed from a player</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.set_default">Roles.set_default (name)</a></td>
<td class="summary">Sets the default role which every player will have, this needs to be called at least once</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.set_root">Roles.set_root (name)</a></td>
<td class="summary">Sets the root role which will always have all permissions, any server actions act from this role</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles.new_role">Roles.new_role (name[, short_hand=name])</a></td>
<td class="summary">Defines a new role and returns the prototype to allow configuration</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_allow_all">Roles._prototype:set_allow_all ([state=true])</a></td>
<td class="summary">Sets the default allow state of the role, true will allow all actions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:allow">Roles._prototype:allow (actions)</a></td>
<td class="summary">Sets the allow actions for this role, actions in this list will be allowed for this role</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:disallow">Roles._prototype:disallow (actions)</a></td>
<td class="summary">Sets the disallow actions for this role, will prevent actions from being allowed regardless of inheritance</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:is_allowed">Roles._prototype:is_allowed (action)</a></td>
<td class="summary">Test for if a role is allowed the given action, mostly internal see Roles.player_allowed</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_flag">Roles._prototype:set_flag (name[, value=true])</a></td>
<td class="summary">Sets the state of a flag for a role, flags can be used to apply effects to players</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:clear_flags">Roles._prototype:clear_flags ()</a></td>
<td class="summary">Clears all flags from this role, individual flags can be removed with set_flag(name,false)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:has_flag">Roles._prototype:has_flag (name)</a></td>
<td class="summary">A test for if the role has a flag set</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_custom_tag">Roles._prototype:set_custom_tag (tag)</a></td>
<td class="summary">Sets a custom player tag for the role, can be accessed by other code</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_custom_color">Roles._prototype:set_custom_color (color)</a></td>
<td class="summary">Sets a custom colour for the role, can be accessed by other code</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_permission_group">Roles._prototype:set_permission_group (name[, use_factorio_api=false])</a></td>
<td class="summary">Sets the permission group for this role, players will be moved to the group of they highest role</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_parent">Roles._prototype:set_parent (role)</a></td>
<td class="summary">Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
nb: this is a recursive action, and changing the allows and disallows will effect all children roles</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_auto_promote_condition">Roles._prototype:set_auto_promote_condition (callback)</a></td>
<td class="summary">Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
nb: this is one way, failing false after already gaining the role will not revoke the role</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:set_block_auto_promote">Roles._prototype:set_block_auto_promote ([state=true])</a></td>
<td class="summary">Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:add_player">Roles._prototype:add_player (player, skip_check, skip_event)</a></td>
<td class="summary">Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:remove_player">Roles._prototype:remove_player (player, skip_check, skip_event)</a></td>
<td class="summary">Removes a player from this role, players can have more than one role at a time, used internally see Roles.unassign</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:get_players">Roles._prototype:get_players ([online=nil])</a></td>
<td class="summary">Returns an array of all the players who have this role, can be filtered by online status</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Roles._prototype:print">Roles._prototype:print (message)</a></td>
<td class="summary">Will print a message to all players with this role</td>
</tr>
</table>
<br/>
<br/>
<h2><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "Roles.debug"></a>
<strong>Roles.debug ()</strong>
</dt>
<dd>
Returns a string which contains all roles in index order displaying all data for them
<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 debug output string
</ol>
</dd>
<dt>
<a name = "Roles.print_to_roles"></a>
<strong>Roles.print_to_roles (roles, message)</strong>
</dt>
<dd>
Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">roles</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 roles which to send the message to
</li>
<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 to send to the players
</li>
</ul>
</dd>
<dt>
<a name = "Roles.print_to_roles_higher"></a>
<strong>Roles.print_to_roles_higher (role, message)</strong>
</dt>
<dd>
Prints a message to all players who have the given role or one which is higher (excluding default)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">role</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 role to send the message to
</li>
<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 to send to the players
</li>
</ul>
</dd>
<dt>
<a name = "Roles.print_to_roles_lower"></a>
<strong>Roles.print_to_roles_lower (role, message)</strong>
</dt>
<dd>
Prints a message to all players who have the given role or one which is lower (excluding default)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">role</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 role to send the message to
</li>
<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 to send to the players
</li>
</ul>
</dd>
<dt>
<a name = "Roles.get_role_by_name"></a>
<strong>Roles.get_role_by_name (name)</strong>
</dt>
<dd>
Get a role for the given name
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 role to get
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
the role with that name or nil
</ol>
</dd>
<dt>
<a name = "Roles.get_role_by_order"></a>
<strong>Roles.get_role_by_order (index)</strong>
</dt>
<dd>
Get a role with the given order index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
the place in the oder list of the role to get
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
the role with that index in the order list or nil
</ol>
</dd>
<dt>
<a name = "Roles.get_role_from_any"></a>
<strong>Roles.get_role_from_any (any)</strong>
</dt>
<dd>
Gets a role from a name,index or role object (where it is just returned)
nb: this function is used for the input for most outward facing functions
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">any</span>
<span class="types"><span class="type">number</span>, <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 value used to find the role
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
the role that was found or nil see above
</ol>
</dd>
<dt>
<a name = "Roles.get_player_roles"></a>
<strong>Roles.get_player_roles (player)</strong>
</dt>
<dd>
Gets all the roles of the given player, this will always contain the default role
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player to get the roles 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 where the values are the roles which the player has
</ol>
</dd>
<dt>
<a name = "Roles.get_player_highest_role"></a>
<strong>Roles.get_player_highest_role (player)</strong>
</dt>
<dd>
Gets the highest role which the player has, can be used to compeer one player to another
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player to get the highest role of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">the</span></span>
role with the highest order index which this player has
</ol>
</dd>
<dt>
<a name = "Roles.assign_player"></a>
<strong>Roles.assign_player (player, roles[, by_player_name=<server>[, silent=false]])</strong>
</dt>
<dd>
Gives a player the given role(s) with an option to pass a by player name used in the log
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player that will be assigned the roles
</li>
<li><span class="parameter">roles</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 roles that the player will be given, can be one role and can be role names
</li>
<li><span class="parameter">by_player_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 player that will be shown in the log
(<em>default</em> <server>)
</li>
<li><span class="parameter">silent</span>
<span class="types"><span class="type">boolean</span></span>
when true there will be no game message printed
(<em>default</em> false)
</li>
</ul>
</dd>
<dt>
<a name = "Roles.unassign_player"></a>
<strong>Roles.unassign_player (player, roles[, by_player_name=<server>[, silent=false]])</strong>
</dt>
<dd>
Removes a player from the given role(s) with an option to pass a by player name used in the log
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player that will have the roles removed
</li>
<li><span class="parameter">roles</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 roles to be removed from the player, can be one role and can be role names
</li>
<li><span class="parameter">by_player_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 player that will be shown in the logs
(<em>default</em> <server>)
</li>
<li><span class="parameter">silent</span>
<span class="types"><span class="type">boolean</span></span>
when true there will be no game message printed
(<em>default</em> false)
</li>
</ul>
</dd>
<dt>
<a name = "Roles.override_player_roles"></a>
<strong>Roles.override_player_roles (roles)</strong>
</dt>
<dd>
Overrides all player roles with the given table of roles, useful to mass set roles on game start
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">roles</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
table a which is indexed by case sensitive player names and has the value of a table of role names
</li>
</ul>
</dd>
<dt>
<a name = "Roles.player_has_role"></a>
<strong>Roles.player_has_role (player, search_role)</strong>
</dt>
<dd>
A test for weather a player has the given role
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player to test the roles of
</li>
<li><span class="parameter">search_role</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a>, <span class="type">number</span> or <a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
a pointer to the role that is being searched for
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the player has the role, false otherwise, nil for errors
</ol>
</dd>
<dt>
<a name = "Roles.player_has_flag"></a>
<strong>Roles.player_has_flag (player, flag_name)</strong>
</dt>
<dd>
A test for weather a player has the given flag true for at least one of they roles
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player to test the roles of
</li>
<li><span class="parameter">flag_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 flag that is being looked for
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the player has at least one role which has the flag set to true, false otherwise, nil for errors
</ol>
</dd>
<dt>
<a name = "Roles.player_allowed"></a>
<strong>Roles.player_allowed (player, action)</strong>
</dt>
<dd>
A test for weather a player has at least one role which is allowed the given action
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player to test the roles of
</li>
<li><span class="parameter">action</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 action that is being tested for
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the player has at least one role which is allowed this action, false otherwise, nil for errors
</ol>
</dd>
<dt>
<a name = "Roles.define_role_order"></a>
<strong>Roles.define_role_order (order)</strong>
</dt>
<dd>
Used to set the role order, higher in the list is better, must be called at least once in config
nb: function also re links parents due to expected position in the config file
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">order</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
table a which is keyed only by numbers (start 1) and values are roles in order with highest first
</li>
</ul>
</dd>
<dt>
<a name = "Roles.define_flag_trigger"></a>
<strong>Roles.define_flag_trigger (name, callback)</strong>
</dt>
<dd>
Defines a new trigger for when a tag is added or removed from a player
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 flag which the roles will have
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
the function that is called when roles are assigned
flag param - player - the player that has had they roles changed
flag param - state - the state of the flag, aka if the flag is present
</li>
</ul>
</dd>
<dt>
<a name = "Roles.set_default"></a>
<strong>Roles.set_default (name)</strong>
</dt>
<dd>
Sets the default role which every player will have, this needs to be called at least once
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 default role
</li>
</ul>
</dd>
<dt>
<a name = "Roles.set_root"></a>
<strong>Roles.set_root (name)</strong>
</dt>
<dd>
Sets the root role which will always have all permissions, any server actions act from this role
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 root role
</li>
</ul>
</dd>
<dt>
<a name = "Roles.new_role"></a>
<strong>Roles.new_role (name[, short_hand=name])</strong>
</dt>
<dd>
Defines a new role and returns the prototype to allow configuration
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 new role, must be unique
</li>
<li><span class="parameter">short_hand</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the shortened version of the name
(<em>default</em> name)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
the start of the config chain for this role
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_allow_all"></a>
<strong>Roles._prototype:set_allow_all ([state=true])</strong>
</dt>
<dd>
Sets the default allow state of the role, true will allow all actions
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">boolean</span></span>
true will allow all actions
(<em>default</em> true)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:allow"></a>
<strong>Roles._prototype:allow (actions)</strong>
</dt>
<dd>
Sets the allow actions for this role, actions in this list will be allowed for this role
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">actions</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
indexed with numbers and is an array of action names, order has no effect
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:disallow"></a>
<strong>Roles._prototype:disallow (actions)</strong>
</dt>
<dd>
Sets the disallow actions for this role, will prevent actions from being allowed regardless of inheritance
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">actions</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.5">table</a></span>
indexed with numbers and is an array of action names, order has no effect
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:is_allowed"></a>
<strong>Roles._prototype:is_allowed (action)</strong>
</dt>
<dd>
Test for if a role is allowed the given action, mostly internal see Roles.player_allowed
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">action</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 action to test if it is allowed
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if action is allowed, false otherwise
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_flag"></a>
<strong>Roles._prototype:set_flag (name[, value=true])</strong>
</dt>
<dd>
Sets the state of a flag for a role, flags can be used to apply effects to players
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 flag to set the value of
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">boolean</span></span>
the state to set the flag to
(<em>default</em> true)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:clear_flags"></a>
<strong>Roles._prototype:clear_flags ()</strong>
</dt>
<dd>
Clears all flags from this role, individual flags can be removed with set_flag(name,false)
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:has_flag"></a>
<strong>Roles._prototype:has_flag (name)</strong>
</dt>
<dd>
A test for if the role has a flag set
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 flag to test for
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the flag is set, false otherwise
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_custom_tag"></a>
<strong>Roles._prototype:set_custom_tag (tag)</strong>
</dt>
<dd>
Sets a custom player tag for the role, can be accessed by other code
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">tag</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span>
the value that the tag will be
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_custom_color"></a>
<strong>Roles._prototype:set_custom_color (color)</strong>
</dt>
<dd>
Sets a custom colour for the role, can be accessed by other code
<h3>Parameters:</h3>
<ul>
<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>
?string|table can either be and rgb colour or the name of a colour defined in the presets
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_permission_group"></a>
<strong>Roles._prototype:set_permission_group (name[, use_factorio_api=false])</strong>
</dt>
<dd>
Sets the permission group for this role, players will be moved to the group of they highest role
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">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 permission group to have players moved to
</li>
<li><span class="parameter">use_factorio_api</span>
<span class="types"><span class="type">boolean</span></span>
when true the custom permission group module is ignored
(<em>default</em> false)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_parent"></a>
<strong>Roles._prototype:set_parent (role)</strong>
</dt>
<dd>
Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
nb: this is a recursive action, and changing the allows and disallows will effect all children roles
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">role</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 role that will be the parent; has imminent effect if role is already defined
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_auto_promote_condition"></a>
<strong>Roles._prototype:set_auto_promote_condition (callback)</strong>
</dt>
<dd>
Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
nb: this is one way, failing false after already gaining the role will not revoke the role
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
receives only one param which is player to promote, return true to promote the player
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:set_block_auto_promote"></a>
<strong>Roles._prototype:set_block_auto_promote ([state=true])</strong>
</dt>
<dd>
Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">boolean</span></span>
when true the players with this role will not be auto promoted
(<em>default</em> true)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Roles._prototype</span></span>
allows chaining
</ol>
</dd>
<dt>
<a name = "Roles._prototype:add_player"></a>
<strong>Roles._prototype:add_player (player, skip_check, skip_event)</strong>
</dt>
<dd>
Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player that will be given this role
</li>
<li><span class="parameter">skip_check</span>
<span class="types"><span class="type">boolean</span></span>
when true player will be taken as the player name (use when player has not yet joined)
</li>
<li><span class="parameter">skip_event</span>
<span class="types"><span class="type">boolean</span></span>
when true the event emit will be skipped, this is used internally with Roles.assign
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the player was added successfully
</ol>
</dd>
<dt>
<a name = "Roles._prototype:remove_player"></a>
<strong>Roles._prototype:remove_player (player, skip_check, skip_event)</strong>
</dt>
<dd>
Removes a player from this role, players can have more than one role at a time, used internally see Roles.unassign
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">player</span>
<span class="types"><span class="type">LuaPlayer</span></span>
the player that will lose this role
</li>
<li><span class="parameter">skip_check</span>
<span class="types"><span class="type">boolean</span></span>
when true player will be taken as the player name (use when player has not yet joined)
</li>
<li><span class="parameter">skip_event</span>
<span class="types"><span class="type">boolean</span></span>
when true the event emit will be skipped, this is used internally with Roles.unassign
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the player was removed successfully
</ol>
</dd>
<dt>
<a name = "Roles._prototype:get_players"></a>
<strong>Roles._prototype:get_players ([online=nil])</strong>
</dt>
<dd>
Returns an array of all the players who have this role, can be filtered by online status
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">online</span>
<span class="types"><span class="type">boolean</span></span>
when given will filter by this online state, nil will return all players
(<em>default</em> nil)
</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>
all the players who have this role, indexed order is meaningless
</ol>
</dd>
<dt>
<a name = "Roles._prototype:print"></a>
<strong>Roles._prototype:print (message)</strong>
</dt>
<dd>
Will print a message to all players with this role
<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 printed to the players
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
the number of players who received the message
</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>