Files
factorio-scenario-ExpCluster/docs/core/Roles.html
2020-11-15 23:26:18 +00:00

3403 lines
111 KiB
HTML

<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Roles core</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../spectre.min.css" type="text/css" />
<link rel="stylesheet" href="../spectre-icons.min.css" type="text/css" />
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div class="container grid-1280">
<div class="columns">
<!-- sidebar start -->
<div id="sidebar" class="column col-3 col-sm-12">
<div class="sidebar-custom">
<div class="project-infobox">
<!-- project title -->
<a href="../index.html"><h1>ExpGaming Scenario</h1></a>
<!-- project description -->
<p class="project-desc">Explosive Gaming's server scenario for 0.18</p>
<!-- project full description -->
</div>
<!-- sidebar navigation -->
<!-- list of items in a module -->
<ul class="nav nav-module-contents">
<li class="nav-item">
<h2>Sections</h2>
<ul class="nav">
<li class="nav-item"><a href="#Dependencies"><span class="fragment-hashtag">#</span> Dependencies</a></li>
<li class="nav-item"><a href="#Getter"><span class="fragment-hashtag">#</span> Getter </a></li>
<li class="nav-item"><a href="#Assignment"><span class="fragment-hashtag">#</span> Assignment </a></li>
<li class="nav-item"><a href="#Checks"><span class="fragment-hashtag">#</span> Checks </a></li>
<li class="nav-item"><a href="#Definitions"><span class="fragment-hashtag">#</span> Definitions </a></li>
<li class="nav-item"><a href="#Role_Actions"><span class="fragment-hashtag">#</span> Role Actions </a></li>
<li class="nav-item"><a href="#Role_Flags"><span class="fragment-hashtag">#</span> Role Flags </a></li>
<li class="nav-item"><a href="#Role_Properties"><span class="fragment-hashtag">#</span> Role Properties </a></li>
<li class="nav-item"><a href="#Role_Players"><span class="fragment-hashtag">#</span> Role Players </a></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Core</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Async.html"><span class="module-name-item">Async</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Commands.html"><span class="module-name-item">Commands</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Common.html"><span class="module-name-item">Common</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Datastore.html"><span class="module-name-item">Datastore</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/External.html"><span class="module-name-item">External</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Gui.html"><span class="module-name-item">Gui</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Groups.html"><span class="module-name-item">Groups</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/PlayerData.html"><span class="module-name-item">PlayerData</span></a></div></li>
<li class="nav-item active"><div class="nav-item-block-active block"><a href="../core/Roles.html"><span class="module-name-item">Roles</span></a><i class="icon icon-arrow-left icon-arrow-left-custom"></i></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Control</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Jail.html"><span class="module-name-item">Jail</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Production.html"><span class="module-name-item">Production</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Reports.html"><span class="module-name-item">Reports</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Rockets.html"><span class="module-name-item">Rockets</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Tasks.html"><span class="module-name-item">Tasks</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Warnings.html"><span class="module-name-item">Warnings</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../control/Warps.html"><span class="module-name-item">Warps</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Addons</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Advanced-Start.html"><span class="module-name-item">Advanced-Start</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Chat-Popups.html"><span class="module-name-item">Chat-Popups</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Chat-Reply.html"><span class="module-name-item">Chat-Reply</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Compilatron.html"><span class="module-name-item">Compilatron</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Damage-Popups.html"><span class="module-name-item">Damage-Popups</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Death-Logger.html"><span class="module-name-item">Death-Logger</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Discord-Alerts.html"><span class="module-name-item">Discord-Alerts</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Inventory-Clear.html"><span class="module-name-item">Inventory-Clear</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Pollution-Grading.html"><span class="module-name-item">Pollution-Grading</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Scorched-Earth.html"><span class="module-name-item">Scorched-Earth</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Spawn-Area.html"><span class="module-name-item">Spawn-Area</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../addons/Tree-Decon.html"><span class="module-name-item">Tree-Decon</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Guis</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Autofill.html"><span class="module-name-item">Autofill</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Player-List.html"><span class="module-name-item">Player-List</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Readme.html"><span class="module-name-item">Readme</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Rocket-Info.html"><span class="module-name-item">Rocket-Info</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Science-Info.html"><span class="module-name-item">Science-Info</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/server-ups.html"><span class="module-name-item">server-ups</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Task-List.html"><span class="module-name-item">Task-List</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../guis/Warps-List.html"><span class="module-name-item">Warps-List</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Data</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../data/Alt-View.html"><span class="module-name-item">Alt-View</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../data/Bonus.html"><span class="module-name-item">Bonus</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../data/Greetings.html"><span class="module-name-item">Greetings</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../data/Player-Colours.html"><span class="module-name-item">Player-Colours</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../data/Quickbar.html"><span class="module-name-item">Quickbar</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../data/Tag.html"><span class="module-name-item">Tag</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Commands</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Admin-Chat.html"><span class="module-name-item">Admin-Chat</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Cheat-Mode.html"><span class="module-name-item">Cheat-Mode</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Clear-Inventory.html"><span class="module-name-item">Clear-Inventory</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Connect.html"><span class="module-name-item">Connect</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Debug.html"><span class="module-name-item">Debug</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Find.html"><span class="module-name-item">Find</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Help.html"><span class="module-name-item">Help</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Home.html"><span class="module-name-item">Home</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Interface.html"><span class="module-name-item">Interface</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Jail.html"><span class="module-name-item">Jail</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Kill.html"><span class="module-name-item">Kill</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Me.html"><span class="module-name-item">Me</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Rainbow.html"><span class="module-name-item">Rainbow</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Repair.html"><span class="module-name-item">Repair</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Reports.html"><span class="module-name-item">Reports</span></a></div></li>
<li class="nav-item active"><div class="nav-item-block-active block"><a href="../commands/Roles.html"><span class="module-name-item">Roles</span></a><i class="icon icon-arrow-left icon-arrow-left-custom"></i></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Spawn.html"><span class="module-name-item">Spawn</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Teleport.html"><span class="module-name-item">Teleport</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../commands/Warnings.html"><span class="module-name-item">Warnings</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Configs</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/File-Loader.html"><span class="module-name-item">File-Loader</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Advanced-Start.html"><span class="module-name-item">Advanced-Start</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Bonuses.html"><span class="module-name-item">Bonuses</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Chat-Reply.html"><span class="module-name-item">Chat-Reply</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Compilatron.html"><span class="module-name-item">Compilatron</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Death-Logger.html"><span class="module-name-item">Death-Logger</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Discord-Alerts.html"><span class="module-name-item">Discord-Alerts</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Commands-Auth-Admin.html"><span class="module-name-item">Commands-Auth-Admin</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Commands-Auth-Roles.html"><span class="module-name-item">Commands-Auth-Roles</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Commands-Color-Parse.html"><span class="module-name-item">Commands-Color-Parse</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Commands-Parse.html"><span class="module-name-item">Commands-Parse</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Commands-Parse-Roles.html"><span class="module-name-item">Commands-Parse-Roles</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Commands-Auth-Runtime-Disable.html"><span class="module-name-item">Commands-Auth-Runtime-Disable</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Permission-Groups.html"><span class="module-name-item">Permission-Groups</span></a></div></li>
<li class="nav-item active"><div class="nav-item-block-active block"><a href="../configs/Roles.html"><span class="module-name-item">Roles</span></a><i class="icon icon-arrow-left icon-arrow-left-custom"></i></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Autofill.html"><span class="module-name-item">Autofill</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Player-List.html"><span class="module-name-item">Player-List</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Rockets.html"><span class="module-name-item">Rockets</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Science.html"><span class="module-name-item">Science</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Tasks.html"><span class="module-name-item">Tasks</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Warps.html"><span class="module-name-item">Warps</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/inventory_clear.html"><span class="module-name-item">inventory_clear</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Pollution-Grading.html"><span class="module-name-item">Pollution-Grading</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Popup-Messages.html"><span class="module-name-item">Popup-Messages</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Preset-Player-Colours.html"><span class="module-name-item">Preset-Player-Colours</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Preset-Player-Quickbar.html"><span class="module-name-item">Preset-Player-Quickbar</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Repair.html"><span class="module-name-item">Repair</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Scorched-Earth.html"><span class="module-name-item">Scorched-Earth</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Spawn-Area.html"><span class="module-name-item">Spawn-Area</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Statistics.html"><span class="module-name-item">Statistics</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../configs/Warnings.html"><span class="module-name-item">Warnings</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Modules</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/control.html"><span class="module-name-item">control</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/modules.addons.station-auto-name.html"><span class="module-name-item">modules.addons.station-auto-name</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/overrides.debug.html"><span class="module-name-item">overrides.debug</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/overrides.math.html"><span class="module-name-item">overrides.math</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/overrides.table.html"><span class="module-name-item">overrides.table</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.event.html"><span class="module-name-item">utils.event</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.event_core.html"><span class="module-name-item">utils.event_core</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.task.html"><span class="module-name-item">utils.task</span></a></div></li>
</ul>
</li>
</ul>
<ul class="nav nav-modules">
<li class="nav-item">
<h2>Topics</h2>
<ul class="nav">
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../topics/README.md.html"><span class="module-name-item">README.md</span></a></div></li>
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../topics/LICENSE.html"><span class="module-name-item">LICENSE</span></a></div></li>
</ul>
</li>
</ul>
</div>
<div class="up-to-top">
<!-- list of items in a module -->
<ul class="nav nav-module-contents">
<li class="nav-item">
<h4>Jump to Section</h4>
<ul class="nav">
<li class="nav-item"><a href="#Dependencies"><span class="fragment-hashtag">#</span> Dependencies</a></li>
<li class="nav-item"><a href="#Getter"><span class="fragment-hashtag">#</span> Getter </a></li>
<li class="nav-item"><a href="#Assignment"><span class="fragment-hashtag">#</span> Assignment </a></li>
<li class="nav-item"><a href="#Checks"><span class="fragment-hashtag">#</span> Checks </a></li>
<li class="nav-item"><a href="#Definitions"><span class="fragment-hashtag">#</span> Definitions </a></li>
<li class="nav-item"><a href="#Role_Actions"><span class="fragment-hashtag">#</span> Role Actions </a></li>
<li class="nav-item"><a href="#Role_Flags"><span class="fragment-hashtag">#</span> Role Flags </a></li>
<li class="nav-item"><a href="#Role_Properties"><span class="fragment-hashtag">#</span> Role Properties </a></li>
<li class="nav-item"><a href="#Role_Players"><span class="fragment-hashtag">#</span> Role Players </a></li>
</ul>
</li>
</ul>
<a href="#">Top <i class="icon icon-upward"></i></a>
</div>
</div>
<!-- sidebar end -->
<!-- content body start -->
<div class="column col-9 col-sm-12">
<!-- module list on the main page start -->
<!-- module list on the main page end -->
<!-- module contents -->
<!-- module content header start -->
<h2><span class="body-module-name"><strong><em>Roles</em></strong></span> core</h2>
<p>Core Module - Roles
- Factorio role system to manage custom permissions.</p>
<p></p>
<!-- module info start -->
<!-- module info end -->
<!-- module usage start -->
<h3>Usage</h3>
<pre class="code" data-lang="Lua"><code><span class="comment">--- Using Role System (assignment):
</span><span class="comment">--When a map first starts you will want to define on mass all the players you expect to join and the roles to give them:
</span>Roles.override_player_roles{
Cooldude2606 = {<span class="string">'Owner'</span>, <span class="string">'Admin'</span>, <span class="string">'Member'</span>},
NotCooldude2606 = {<span class="string">'Member'</span>}
}
<span class="comment">--Once the game is running you still want to be able to give role and remove them which is when you would use:
</span>Roles.assign_player(player, <span class="string">'Admin'</span>, by_player_name) <span class="comment">-- this will give the "Admin" role to the player
</span>Roles.unassign_player(player, {<span class="string">'Admin'</span>, <span class="string">'Moderator'</span>}, by_player_name) <span class="comment">-- this will remove "Admin" and "Moderator" role in one go
</span></code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">--- Using Role System (role testing):
</span><span class="comment">--To comparer two players you can comparer the index of they highest roles, can be used when you want to allow a "write" down type system:
</span>Roles.get_player_highest_role(playerOne).index &lt; Roles.get_player_highest_role(playerTwo).index <span class="comment">-- remember that less means a higher role
</span>
<span class="comment">--Listing all of a players roles can also be useful which is when you would want to use:
</span>Roles.get_player_roles(player) <span class="comment">-- the return is an array that can be looped over however this is not in particular order
</span>
<span class="comment">--Finally you may want to test if a player has a certain role, flag or action allowed which is when you would use:
</span>Roles.player_has_role(player, <span class="string">'Admin'</span>) <span class="comment">-- you can provide a role name if you only want a name based system
</span>Roles.player_has_flag(player, <span class="string">'is_donator'</span>) <span class="comment">-- your roles can be grouped together with flags such as is_donator
</span>Roles.player_allowed(player, <span class="string">'game modifiers'</span>) <span class="comment">-- or you can have an action based system where each action is something the player can do
</span></code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">--- Example Flag Define:
</span><span class="comment">--Flags can be used to group multiple roles and actions under one catch all, for example if you want a piece of code to only
</span><span class="comment">--be active for your donators then you would add a "is_donator" flag to all your donator roles and then in the code test if
</span><span class="comment">--a player has that tag present:
</span>
<span class="comment">-- give you donators a speed boost when they join; these functions aren't required but can be useful
</span>Roles.define_flag_trigger(<span class="string">'is_donator'</span>, <span class="keyword">function</span>(player, state)
<span class="keyword">if</span> state <span class="keyword">then</span>
player.character_running_speed_modifier = <span class="number">1.5</span>
<span class="keyword">else</span>
player.character_running_speed_modifier = <span class="number">1</span>
<span class="keyword">end</span>
<span class="keyword">end</span>)
<span class="comment">-- then on all your donator roles you would add
</span>Roles.new_role(<span class="string">'Donator'</span>)
:set_flag(<span class="string">'is_donator'</span>)
<span class="comment">-- and in your code you would test for
</span><span class="keyword">if</span> Roles.player_has_flag(player, <span class="string">'is_donator'</span>) <span class="keyword">then</span>
<span class="comment">-- some donator only code
</span><span class="keyword">end</span></code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">--- Example Role Define:
</span><span class="comment">--You can't use a role system without any roles so first you must define your roles; each role has a minimum of a name with
</span><span class="comment">--the option for a shorthand:
</span>Roles.new_role(<span class="string">'Administrator'</span>, <span class="string">'Admin'</span>)
<span class="comment">--Next you will want to add any extras you want to have, such as a tag, colour, permission group or any custom flags:
</span>Roles.new_role(<span class="string">'Administrator'</span>, <span class="string">'Admin'</span>)
:set_custom_tag(<span class="string">'[Admin]'</span>)
:set_custom_color(<span class="string">'red'</span>) <span class="comment">-- this can be {r=0, g=0, b=0} or a predefined value
</span>:set_permission_group(<span class="string">'Staff'</span>) <span class="comment">-- a second argument can be added if you have not used the custom permission group config
</span>:set_flag(<span class="string">'is_admin'</span>)
<span class="comment">--You will then want to decide if you want to allow all actions, this should of course be used sparely:
</span>Roles.new_role(<span class="string">'Administrator'</span>, <span class="string">'Admin'</span>)
...extras...
:set_allow_all()
<span class="comment">--If you don't do this want this as i would advise you do then you will want to define what the role can do; this comes with
</span><span class="comment">--an optional inheritance system if you like those sort of things in which case disallow may also be of some use to you:
</span>Roles.new_role(<span class="string">'Administrator'</span>, <span class="string">'Admin'</span>)
...extras...
:set_parent(<span class="string">'Moderator'</span>) <span class="comment">-- the admin can do anything that a moderator can do
</span>:allow{ <span class="comment">-- these actions can be anything just try to keep them without conflicts
</span> <span class="string">'command/kill'</span>,
<span class="string">'gui/game settings'</span>
}
<span class="comment">--Here is what the finished admin role would look like:
</span>Roles.new_role(<span class="string">'Administrator'</span>, <span class="string">'Admin'</span>)
:set_custom_tag(<span class="string">'[Admin]'</span>)
:set_custom_color(<span class="string">'red'</span>)
:set_permission_group(<span class="string">'Staff'</span>)
:set_flag(<span class="string">'is_admin'</span>)
:set_parent(<span class="string">'Moderator'</span>)
:allow{
<span class="string">'command/kill'</span>,
<span class="string">'gui/game settings'</span>
}</code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">--- Example System Define:
</span><span class="comment">--Once all roles are defined these steps must be done to ensure the system is ready to use, this includes setting a default
</span><span class="comment">--role, assigning a root (all permission) role that the server/system will use and the linear order that the roles fall into:
</span>
Roles.set_default(<span class="string">'Guest'</span>)
Roles.set_root(<span class="string">'System'</span>)
Roles.define_role_order{
<span class="string">'System'</span>,
<span class="string">'Administrator'</span>,
<span class="string">'Moderator'</span>,
<span class="string">'Donator'</span>,
<span class="string">'Guest'</span>
}
<span class="comment">--Just remember that in this example all these roles have not been defined; so make sure all your roles that are used are defined
</span><span class="comment">--before hand; a config file on load is useful for this to ensure that its loaded before the first player even joins.
</span></code></pre>
<!-- module usage end -->
<!-- module content header end -->
<!-- module section list start -->
<table class="section-content-list">
<thead>
<h3><a href="#Dependencies">Dependencies</a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><a href="#utils.game">utils.game</a></td>
</tr>
<tr>
<td class="name"><a href="#utils.global">utils.global</a></td>
</tr>
<tr>
<td class="name"><a href="#utils.event">utils.event</a></td>
</tr>
<tr>
<td class="name"><a href="#expcore.permission_groups">expcore.permission_groups</a></td>
</tr>
<tr>
<td class="name"><a href="#expcore.async">expcore.async</a></td>
</tr>
<tr>
<td class="name"><a href="#utils.color_presets">utils.color_presets</a></td>
</tr>
<tr>
<td class="name"><a href="#expcore.common">expcore.common</a></td>
</tr>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Getter">Getter </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><a href="#debug">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"><a href="#print_to_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"><a href="#print_to_roles_higher">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"><a href="#print_to_roles_lower">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"><a href="#get_role_by_name">get_role_by_name(name)</a></td>
<td class="summary">Get a role for the given name</td>
</tr>
<tr>
<td class="name"><a href="#get_role_by_order">get_role_by_order(index)</a></td>
<td class="summary">Get a role with the given order index</td>
</tr>
<tr>
<td class="name"><a href="#get_role_from_any">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"><a href="#get_player_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"><a href="#get_player_highest_role">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>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Assignment">Assignment </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><a href="#assign_player">assign_player(player, roles[, by_player_name=<server>][, skip_checks=false][, 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"><a href="#unassign_player">unassign_player(player, roles[, by_player_name=<server>][, skip_checks=false][, 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"><a href="#override_player_roles">override_player_roles([player_name], 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>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Checks">Checks </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><a href="#player_has_role">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"><a href="#player_has_flag">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"><a href="#player_allowed">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>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Definitions">Definitions </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><a href="#define_role_order">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"><a href="#define_flag_trigger">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"><a href="#set_default">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"><a href="#set_root">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"><a href="#new_role">new_role(name[, short_hand=name])</a></td>
<td class="summary">Defines a new role and returns the prototype to allow configuration</td>
</tr>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Role_Actions">Role Actions </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><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"><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"><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"><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>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Role_Flags">Role Flags </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><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"><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"><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>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Role_Properties">Role Properties </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><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"><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"><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"><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"><a href="#Roles._prototype:set_auto_assign_condition">Roles._prototype:set_auto_assign_condition(callback)</a></td>
<td class="summary">Sets an auto assign condition that is checked every 60 seconds, if true is returned then the player will receive 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"><a href="#Roles._prototype:get_auto_assign_condition">Roles._prototype:get_auto_assign_condition()</a></td>
<td class="summary">Get the auto assign condition for this role, returns nil if no condition is set</td>
</tr>
<tr>
<td class="name"><a href="#Roles._prototype:set_block_auto_assign">Roles._prototype:set_block_auto_assign([state=true])</a></td>
<td class="summary">Sets the role to not allow players to have auto assign effect them, useful to keep people locked to a role</td>
</tr>
</tbody>
</table>
<table class="section-content-list">
<thead>
<h3><a href="#Role_Players">Role Players </a></h3>
<span></span>
</thead>
<tbody>
<tr>
<td class="name"><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"><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"><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"><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>
</tbody>
</table>
<!-- module section list end -->
<br />
<!-- section start -->
<h3><span id="Dependencies" class="section-title"><a href="#Dependencies">Dependencies</a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#utils.game" class="fragment-hashtag">#</a>
<span class="section-item-title" id="utils.game">utils.game</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#utils.global" class="fragment-hashtag">#</a>
<span class="section-item-title" id="utils.global">utils.global</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#utils.event" class="fragment-hashtag">#</a>
<span class="section-item-title" id="utils.event">utils.event</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#expcore.permission_groups" class="fragment-hashtag">#</a>
<span class="section-item-title" id="expcore.permission_groups">expcore.permission_groups</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#expcore.async" class="fragment-hashtag">#</a>
<span class="section-item-title" id="expcore.async">expcore.async</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#utils.color_presets" class="fragment-hashtag">#</a>
<span class="section-item-title" id="utils.color_presets">utils.color_presets</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#expcore.common" class="fragment-hashtag">#</a>
<span class="section-item-title" id="expcore.common">expcore.common</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<!-- usage end -->
</dd>
</dl>
<h3><span id="Getter" class="section-title"><a href="#Getter">Getter </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#debug" class="fragment-hashtag">#</a>
<span class="section-item-title" id="debug">debug()</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Returns a string which contains all roles in index order displaying all data for them</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
<span class="return-text">the debug output string</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Print the debug string
</span>game.player.<span class="global">print</span>(Roles.<span class="global">debug</span>())</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#print_to_roles" class="fragment-hashtag">#</a>
<span class="section-item-title" id="print_to_roles">print_to_roles(roles, message)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>roles</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
table a of roles which to send the message to
</li>
<li class="section-subitem-li">
<strong><em>message</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the message to send to the players
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Print a message to the given roles
</span>Roles.print_to_roles({<span class="string">'Administrator'</span>, <span class="string">'Moderator'</span>}, <span class="string">'Hello, World!'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#print_to_roles_higher" class="fragment-hashtag">#</a>
<span class="section-item-title" id="print_to_roles_higher">print_to_roles_higher(role, message)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Prints a message to all players who have the given role or one which is higher (excluding default)</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>role</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the role to send the message to
</li>
<li class="section-subitem-li">
<strong><em>message</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the message to send to the players
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Print a message to the roles above this role, includes the given role
</span>Roles.print_to_roles_higher(<span class="string">'Moderator'</span>, <span class="string">'Hello, World!'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#print_to_roles_lower" class="fragment-hashtag">#</a>
<span class="section-item-title" id="print_to_roles_lower">print_to_roles_lower(role, message)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Prints a message to all players who have the given role or one which is lower (excluding default)</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>role</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the role to send the message to
</li>
<li class="section-subitem-li">
<strong><em>message</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the message to send to the players
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Print a message to the roles below this role, includes the given role
</span>Roles.print_to_roles_higher(<span class="string">'Moderator'</span>, <span class="string">'Hello, World!'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#get_role_by_name" class="fragment-hashtag">#</a>
<span class="section-item-title" id="get_role_by_name">get_role_by_name(name)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Get a role for the given name</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the role to get
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">the role with that name or nil</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get a role by its name
</span><span class="keyword">local</span> role = Roles.get_role_by_name(<span class="string">'Moderator'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#get_role_by_order" class="fragment-hashtag">#</a>
<span class="section-item-title" id="get_role_by_order">get_role_by_order(index)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Get a role with the given order index</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>index</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.3.html">number</a></span>)
the place in the order list of the role to get
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">the role with that index in the order list or nil</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get a role by its index in the order list
</span><span class="keyword">local</span> role = Roles.get_role_by_name(<span class="number">2</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#get_role_from_any" class="fragment-hashtag">#</a>
<span class="section-item-title" id="get_role_from_any">get_role_from_any(any)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-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</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>any</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.3.html">number</a>, <a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a> or <a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
the value used to find the role
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">the role that was found or nil see above</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get a role by its name or order
</span><span class="keyword">local</span> role = Roles.get_role_from_any(<span class="string">'Moderator'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#get_player_roles" class="fragment-hashtag">#</a>
<span class="section-item-title" id="get_player_roles">get_player_roles(player)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Gets all the roles of the given player, this will always contain the default role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player to get the roles of
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
<span class="return-text">a table where the values are the roles which the player has</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get the roles that a player has
</span><span class="keyword">local</span> roles = Roles.get_player_roles(game.player)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#get_player_highest_role" class="fragment-hashtag">#</a>
<span class="section-item-title" id="get_player_highest_role">get_player_highest_role(player)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Gets the highest role which the player has, can be used to compeer one player to another</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player to get the highest role of
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">the</span></span>)
<span class="return-text">role with the highest order index which this player has</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get the highest role that a player has
</span><span class="keyword">local</span> role = Roles.get_player_highest_role(game.player)</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Assignment" class="section-title"><a href="#Assignment">Assignment </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#assign_player" class="fragment-hashtag">#</a>
<span class="section-item-title" id="assign_player">assign_player(player, roles[, by_player_name=<server>][, skip_checks=false][, silent=false])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Gives a player the given role(s) with an option to pass a by player name used in the log</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player that will be assigned the roles
</li>
<li class="section-subitem-li">
<strong><em>roles</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
table a of roles that the player will be given, can be one role and can be role names
</li>
<li class="section-subitem-li">
<strong><em>by_player_name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the player that will be shown in the log
(<em>default</em>: <server>)
</li>
<li class="section-subitem-li">
<strong><em>skip_checks</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true there will be no checks are done for if the player is valid
(<em>default</em>: false)
</li>
<li class="section-subitem-li">
<strong><em>silent</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true there will be no game message printed
(<em>default</em>: false)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Assign a player to the Moderator role
</span>Roles.assign_player(game.player, <span class="string">'Moderator'</span>)</code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Assign a player to the Moderator role, even if the player has never been on the map
</span>Roles.assign_player(<span class="string">'Cooldude2606'</span>, <span class="string">'Moderator'</span>, <span class="keyword">nil</span>, <span class="keyword">true</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#unassign_player" class="fragment-hashtag">#</a>
<span class="section-item-title" id="unassign_player">unassign_player(player, roles[, by_player_name=<server>][, skip_checks=false][, silent=false])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Removes a player from the given role(s) with an option to pass a by player name used in the log</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player that will have the roles removed
</li>
<li class="section-subitem-li">
<strong><em>roles</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
table a of roles to be removed from the player, can be one role and can be role names
</li>
<li class="section-subitem-li">
<strong><em>by_player_name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the player that will be shown in the logs
(<em>default</em>: <server>)
</li>
<li class="section-subitem-li">
<strong><em>skip_checks</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true there will be no checks are done for if the player is valid
(<em>default</em>: false)
</li>
<li class="section-subitem-li">
<strong><em>silent</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true there will be no game message printed
(<em>default</em>: false)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Unassign a player from the Moderator role
</span>Roles.unassign_player(game.player, <span class="string">'Moderator'</span>)</code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Unassign a player from the Moderator role, even if the player has never been on the map
</span>Roles.unassign_player(<span class="string">'Cooldude2606'</span>, <span class="string">'Moderator'</span>, <span class="keyword">nil</span>, <span class="keyword">true</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#override_player_roles" class="fragment-hashtag">#</a>
<span class="section-item-title" id="override_player_roles">override_player_roles([player_name], roles)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Overrides all player roles with the given table of roles, useful to mass set roles on game start</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player_name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the player to set the roles for, if not given all roles are overriden
(<em>optional</em>)
</li>
<li class="section-subitem-li">
<strong><em>roles</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">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>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Override the roles of a single player, other users are not effected
</span>Roles.override_player_roles(<span class="string">'Cooldude2606'</span>, {<span class="string">'Moderator'</span>})</code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Override all existing roles, effects all users not just ones listed
</span>Roles.override_player_roles{
[<span class="string">'Cooldude2606'</span>] = {<span class="string">'Administrator'</span>, <span class="string">'Moderator'</span>},
[<span class="string">'arty714'</span>] = {<span class="string">'Administrator'</span>, <span class="string">'Moderator'</span>},
}</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Checks" class="section-title"><a href="#Checks">Checks </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#player_has_role" class="fragment-hashtag">#</a>
<span class="section-item-title" id="player_has_role">player_has_role(player, search_role)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">A test for weather a player has the given role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player to test the roles of
</li>
<li class="section-subitem-li">
<strong><em>search_role</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a>, <a class="type" href="https://www.lua.org/pil/2.3.html">number</a> or <a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
a pointer to the role that is being searched for
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if the player has the role, false otherwise, nil for errors</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Test if a player has a role
</span><span class="keyword">local</span> has_role = Roles.player_has_role(game.player, <span class="string">'Moderator'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#player_has_flag" class="fragment-hashtag">#</a>
<span class="section-item-title" id="player_has_flag">player_has_flag(player, flag_name)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">A test for weather a player has the given flag true for at least one of they roles</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player to test the roles of
</li>
<li class="section-subitem-li">
<strong><em>flag_name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the flag that is being looked for
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if the player has at least one role which has the flag set to true, false otherwise, nil for errors</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Test if a player has a role
</span><span class="keyword">local</span> has_flag = Roles.player_has_flag(game.player, <span class="string">'is_donator'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#player_allowed" class="fragment-hashtag">#</a>
<span class="section-item-title" id="player_allowed">player_allowed(player, action)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">A test for weather a player has at least one role which is allowed the given action</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player to test the roles of
</li>
<li class="section-subitem-li">
<strong><em>action</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the action that is being tested for
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if the player has at least one role which is allowed this action, false otherwise, nil for errors</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Test if a player has a role
</span><span class="keyword">local</span> has_flag = Roles.player_has_flag(game.player, <span class="string">'is_donator'</span>)</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Definitions" class="section-title"><a href="#Definitions">Definitions </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#define_role_order" class="fragment-hashtag">#</a>
<span class="section-item-title" id="define_role_order">define_role_order(order)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-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</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>order</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
table a which is keyed only by numbers (start 1) and values are roles in order with highest first
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Define which roles are higher than others
</span>Roles.define_role_order{
<span class="string">'System'</span>,
<span class="string">'Administrator'</span>,
<span class="string">'Moderator'</span>,
<span class="string">'Donator'</span>,
<span class="string">'Guest'</span>
}</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#define_flag_trigger" class="fragment-hashtag">#</a>
<span class="section-item-title" id="define_flag_trigger">define_flag_trigger(name, callback)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Defines a new trigger for when a tag is added or removed from a player</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the flag which the roles will have
</li>
<li class="section-subitem-li">
<strong><em>callback</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.6.html">function</a></span>)
the function that is called when roles are assigned
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Defining a flag trigger
</span>Roles.define_flag_trigger(<span class="string">'is_donator'</span>, <span class="keyword">function</span>(player, state)
player.character_running_speed_modifier = state <span class="keyword">and</span> <span class="number">1.5</span> <span class="keyword">or</span> <span class="number">1</span>
<span class="keyword">end</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#set_default" class="fragment-hashtag">#</a>
<span class="section-item-title" id="set_default">set_default(name)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the default role which every player will have, this needs to be called at least once</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the default role
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Setting the default role
</span>Roles.set_default(<span class="string">'Guest'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#set_root" class="fragment-hashtag">#</a>
<span class="section-item-title" id="set_root">set_root(name)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the root role which will always have all permissions, any server actions act from this role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the root role
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Setting the root role
</span>Roles.set_root(<span class="string">'System'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#new_role" class="fragment-hashtag">#</a>
<span class="section-item-title" id="new_role">new_role(name[, short_hand=name])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Defines a new role and returns the prototype to allow configuration</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the new role, must be unique
</li>
<li class="section-subitem-li">
<strong><em>short_hand</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the shortened version of the name
(<em>default</em>: name)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">the start of the config chain for this role</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Defining a new role
</span><span class="keyword">local</span> role = Roles.new_role(<span class="string">'Moderator'</span>, <span class="string">'Mod'</span>)</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Role_Actions" class="section-title"><a href="#Role_Actions">Role Actions </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_allow_all" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_allow_all">Roles._prototype:set_allow_all([state=true])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the default allow state of the role, true will allow all actions</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>state</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
true will allow all actions
(<em>default</em>: true)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Allow all actions for this role, useful for root like roles
</span>role:set_allow_all()</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:allow" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:allow">Roles._prototype:allow(actions)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the allow actions for this role, actions in this list will be allowed for this role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>actions</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
indexed with numbers and is an array of action names, order has no effect
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Allow some actions for a role
</span>role:allow{
<span class="string">'command/kill'</span>,
<span class="string">'gui/game settings'</span>
}</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:disallow" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:disallow">Roles._prototype:disallow(actions)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the disallow actions for this role, will prevent actions from being allowed regardless of inheritance</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>actions</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
indexed with numbers and is an array of action names, order has no effect
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Disallow an action for a role, useful if inherit an action from a parent
</span>role:disallow{
<span class="string">'command/kill'</span>,
<span class="string">'gui/game settings'</span>
}</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:is_allowed" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:is_allowed">Roles._prototype:is_allowed(action)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Test for if a role is allowed the given action, mostly internal see Roles.player_allowed</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>action</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the action to test if it is allowed
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if action is allowed, false otherwise</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Test if a role is allowed an action
</span><span class="keyword">local</span> allowed = role:is_allowed(<span class="string">'command/kill'</span>)</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Role_Flags" class="section-title"><a href="#Role_Flags">Role Flags </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_flag" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_flag">Roles._prototype:set_flag(name[, value=true])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the state of a flag for a role, flags can be used to apply effects to players</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the flag to set the value of
</li>
<li class="section-subitem-li">
<strong><em>value</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
the state to set the flag to
(<em>default</em>: true)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Set a flag for a role
</span>role:set_flag(<span class="string">'is_admin'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:clear_flags" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:clear_flags">Roles._prototype:clear_flags()</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Clears all flags from this role, individual flags can be removed with set_flag(name, false)</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Remove all flags from a role
</span>role:clear_flags()</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:has_flag" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:has_flag">Roles._prototype:has_flag(name)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">A test for if the role has a flag set</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the flag to test for
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if the flag is set, false otherwise</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Test if a role has a flag
</span><span class="keyword">local</span> has_flag = role:has_flag(<span class="string">'is_admin'</span>)</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Role_Properties" class="section-title"><a href="#Role_Properties">Role Properties </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_custom_tag" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_custom_tag">Roles._prototype:set_custom_tag(tag)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets a custom player tag for the role, can be accessed by other code</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>tag</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the value that the tag will be
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Set a custom tag for this role, other code is required to set the tag
</span>role:set_custom_tag(<span class="string">'Mod'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_custom_color" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_custom_color">Roles._prototype:set_custom_color(color)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets a custom colour for the role, can be accessed by other code</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>color</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
?string|table can either be and rgb colour or the name of a colour defined in the presets
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Set a custom colour for this role, other code is required to use this value
</span>role:set_custom_color{ r=<span class="number">255</span>, g=<span class="number">100</span>, b=<span class="number">100</span>}</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_permission_group" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_permission_group">Roles._prototype:set_permission_group(name[, use_factorio_api=false])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the permission group for this role, players will be moved to the group of they highest role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>name</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the permission group to have players moved to
</li>
<li class="section-subitem-li">
<strong><em>use_factorio_api</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true the custom permission group module is ignored
(<em>default</em>: false)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Set the permission group for this role, see permission_groups.lua
</span>role:set_permission_group(<span class="string">'Admin'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_parent" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_parent">Roles._prototype:set_parent(role)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-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</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>role</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the name of the role that will be the parent; has imminent effect if role is already defined
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Set the parent for this role to inherit all actions allowed
</span>role:set_parent(<span class="string">'Guest'</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_auto_assign_condition" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_auto_assign_condition">Roles._prototype:set_auto_assign_condition(callback)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets an auto assign condition that is checked every 60 seconds, if true is returned then the player will receive the role
nb: this is one way, failing false after already gaining the role will not revoke the role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>callback</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.6.html">function</a></span>)
receives only one param which is player to assign, return true to assign the player
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Give this role to a user if there are admin, ran every 60 seconds
</span>role:set_auto_assign_condition(<span class="keyword">function</span>(player)
<span class="keyword">return</span> player.admin
<span class="keyword">end</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:get_auto_assign_condition" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:get_auto_assign_condition">Roles._prototype:get_auto_assign_condition()</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Get the auto assign condition for this role, returns nil if no condition is set</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.6.html">function</a></span>)
<span class="return-text">The callback which was assigned as the auto assign condition</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Give this role to a user if there are admin, ran every 60 seconds
</span><span class="keyword">local</span> condition = role:get_auto_assign_condition()</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:set_block_auto_assign" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:set_block_auto_assign">Roles._prototype:set_block_auto_assign([state=true])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Sets the role to not allow players to have auto assign effect them, useful to keep people locked to a role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>state</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true the players with this role will not be auto assigned to other roles
(<em>default</em>: true)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><span class="type">Roles._prototype</span></span>)
<span class="return-text">allows chaining</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Make a role stop players from being auto assigned to other roles
</span>role:set_block_auto_assign()</code></pre>
<!-- usage end -->
</dd>
</dl>
<h3><span id="Role_Players" class="section-title"><a href="#Role_Players">Role Players </a></span></h3>
<dl class="section-body-container">
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:add_player" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:add_player">Roles._prototype:add_player(player, skip_check, skip_event)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player that will be given this role
</li>
<li class="section-subitem-li">
<strong><em>skip_check</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true player will be taken as the player name (use when player has not yet joined)
</li>
<li class="section-subitem-li">
<strong><em>skip_event</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true the event emit will be skipped, this is used internally with Roles.assign
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if the player was added successfully</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Assign a player to this role
</span>role:add_player(game.player)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:remove_player" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:remove_player">Roles._prototype:remove_player(player, skip_check, skip_event)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Removes a player from this role, players can have more than one role at a time, used internally see Roles.unassign</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>player</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/LuaPlayer.html">LuaPlayer</a></span>)
the player that will lose this role
</li>
<li class="section-subitem-li">
<strong><em>skip_check</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true player will be taken as the player name (use when player has not yet joined)
</li>
<li class="section-subitem-li">
<strong><em>skip_event</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when true the event emit will be skipped, this is used internally with Roles.unassign
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
<span class="return-text">true if the player was removed successfully</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Unassign a player from this role
</span>role:remove_player(game.player)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:get_players" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:get_players">Roles._prototype:get_players([online=nil])</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Returns an array of all the players who have this role, can be filtered by online status</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>online</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#boolean">boolean</a></span>)
when given will filter by this online state, nil will return all players
(<em>default</em>: nil)
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.5.html">table</a></span>)
<span class="return-text">all the players who have this role, indexed order is meaningless</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get all the players with this role
</span><span class="keyword">local</span> players = role:get_players()</code></pre>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Get all online players with this role
</span><span class="keyword">local</span> players = role:get_players(<span class="keyword">true</span>)</code></pre>
<!-- usage end -->
</dd>
<dt>
<div class="divider divider-custom"></div>
<div class="block section-item-header">
<a href="#Roles._prototype:print" class="fragment-hashtag">#</a>
<span class="section-item-title" id="Roles._prototype:print">Roles._prototype:print(message)</span>
</div>
</dt>
<dd>
<div class="section-item-body">
<p class="section-item-summary">Will print a message to all players with this role</p>
<p class="section-item-description"></p>
<!-- parameters start -->
<strong>Parameters:</strong>
<ul>
<li class="section-subitem-li">
<strong><em>message</em></strong>
<strong> : </strong>
(<span class="types"><a class="type" href="http://lua-api.factorio.com/latest/Builtin-Types.html#string">string</a></span>)
the message that will be printed to the players
</li>
</ul>
<!-- parameters end -->
<!-- returns start -->
<strong>Returns:</strong>
<ul>
<li>
(<span class="types"><a class="type" href="https://www.lua.org/pil/2.3.html">number</a></span>)
<span class="return-text">the number of players who received the message</span>
</li>
</ul>
<!-- returns end -->
<!-- see also start -->
<!-- see also end -->
<!-- usage start -->
<strong>Usage:</strong>
<pre class="code" data-lang="Lua"><code><span class="comment">-- Print a message to all players with this role
</span>role:<span class="global">print</span>(<span class="string">'Hello, World!'</span>)</code></pre>
<!-- usage end -->
</dd>
</dl>
<!-- section end -->
</div>
</div>
</div>
<div class="footer container grid-1280">
<div class="divider divider-custom"></div>
<div class="footer-columns columns">
<div class="sidebar-footer column col-3 col-sm-12">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc </a></i>
</div>
<div class="content-footer column col-9 col-sm-12">
<i>Last updated 2020-11-15 23:26:16 UTC</i>
</div>
</div>
</div>
</body>
</html>