mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Updated Docs
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<a href="../index.html"><h1>ExpGaming Scenario</h1></a>
|
||||
|
||||
<!-- project description -->
|
||||
<p class="project-desc">Explosive Gaming's server scenario for 0.17</p>
|
||||
<p class="project-desc">Explosive Gaming's server scenario for 0.18</p>
|
||||
|
||||
<!-- project full description -->
|
||||
</div>
|
||||
@@ -57,13 +57,13 @@
|
||||
<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-Library.html"><span class="module-name-item">Common-Library</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/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/Permissions-Groups.html"><span class="module-name-item">Permissions-Groups</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 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>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Store.html"><span class="module-name-item">Store</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../core/Sudo.html"><span class="module-name-item">Sudo</span></a></div></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -92,10 +92,12 @@
|
||||
<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/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="../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/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="../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>
|
||||
@@ -104,8 +106,10 @@
|
||||
<h2>Guis</h2>
|
||||
<ul class="nav">
|
||||
<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>
|
||||
@@ -143,7 +147,6 @@
|
||||
<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/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/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>
|
||||
@@ -152,22 +155,23 @@
|
||||
<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-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/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/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/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/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/Rockets.html"><span class="module-name-item">Rockets</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/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/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/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/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="../configs/Warps.html"><span class="module-name-item">Warps</span></a></div></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -176,18 +180,13 @@
|
||||
<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/utils.alien_evolution_progress.html"><span class="module-name-item">utils.alien_evolution_progress</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.core.html"><span class="module-name-item">utils.core</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.debug.html"><span class="module-name-item">utils.debug</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.dump_env.html"><span class="module-name-item">utils.dump_env</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.math.html"><span class="module-name-item">utils.math</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.recipe_locker.html"><span class="module-name-item">utils.recipe_locker</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.state_machine.html"><span class="module-name-item">utils.state_machine</span></a></div></li>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.table.html"><span class="module-name-item">utils.table</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>
|
||||
<li class="nav-item"><div class="nav-item-block-inactive block"><a href="../modules/utils.timestamp.html"><span class="module-name-item">utils.timestamp</span></a></div></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -238,7 +237,7 @@
|
||||
|
||||
<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>
|
||||
- Factorio role system to manage custom permissions.</p>
|
||||
<p></p>
|
||||
|
||||
|
||||
@@ -247,111 +246,107 @@
|
||||
|
||||
<!-- module usage start -->
|
||||
<h3>Usage</h3>
|
||||
<pre class="code" data-lang="Lua"><code>
|
||||
<span class="comment">---- Using Role System (Frontend):
|
||||
</span> When a map first starts you will want to define on mass all the players you expect to join <span class="keyword">and</span> the roles to give them:
|
||||
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>}
|
||||
}
|
||||
<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>}
|
||||
}
|
||||
|
||||
Once the game is running you still want to be able to give role <span class="keyword">and</span> remove them which is when you would use:
|
||||
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 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 (Backend):
|
||||
</span> To comparer two players you can comparer the index of they highest roles, can be used when you want to allow a <span class="string">"write"</span> down <span class="global">type</span> system:
|
||||
Roles.get_player_highest_role(playerOne).index < Roles.get_player_highest_role(playerTwo).index <span class="comment">-- remember that less means a higher role
|
||||
<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 < Roles.get_player_highest_role(playerTwo).index <span class="comment">-- remember that less means a higher role
|
||||
</span>
|
||||
Listing all of a players roles can also be useful which is when you would want to use:
|
||||
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 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>
|
||||
Finally you may want to test <span class="keyword">if</span> a player has a certain role, flag <span class="keyword">or</span> action allowed which is when you would use:
|
||||
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 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> Flags can be used to group multiple roles <span class="keyword">and</span> actions under one catch all, <span class="keyword">for</span> example <span class="keyword">if</span> you want a piece of code to only
|
||||
be active <span class="keyword">for</span> your donators <span class="keyword">then</span> you would add a <span class="string">"is_donator"</span> flag to all your donator roles <span class="keyword">and</span> <span class="keyword">then</span> <span class="keyword">in</span> the code test <span class="keyword">if</span>
|
||||
a player has that tag present:
|
||||
<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">-- 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">-- 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">-- 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> You can<span class="string">'t use a role system without any roles so first you must define your roles; each role has a minimum of a name with
|
||||
the option for a shorthand:
|
||||
Roles.new_role('</span>Administrator<span class="string">','</span>Admin<span class="string">')
|
||||
<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>)
|
||||
|
||||
Next you will want to add any extras you want to have, such as a tag, colour, permission group or any custom flags:
|
||||
Roles.new_role('</span>Administrator<span class="string">','</span>Admin<span class="string">')
|
||||
:set_custom_tag('</span>[Admin]<span class="string">')
|
||||
:set_custom_color('</span>red<span class="string">') -- this can be {r=0,g=0,b=0} or a predefined value
|
||||
:set_permission_group('</span>Staff<span class="string">') -- a second argument can be added if you have not used the custom permission group config
|
||||
:set_flag('</span>is_admin<span class="string">')
|
||||
<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()
|
||||
|
||||
You will then want to decide if you want to allow all actions, this should of course be used sparely:
|
||||
Roles.new_role('</span>Administrator<span class="string">','</span>Admin<span class="string">')
|
||||
...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>
|
||||
}
|
||||
|
||||
If you don'</span>t <span class="keyword">do</span> this want this as i would advise you <span class="keyword">do</span> <span class="keyword">then</span> you will want to define what the role can <span class="keyword">do</span>; this comes with
|
||||
an optional inheritance system <span class="keyword">if</span> you like those sort of things <span class="keyword">in</span> which case disallow may also be of some use to you:
|
||||
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>)
|
||||
|
||||
Here is what the finished admin role would look like:
|
||||
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> Once all roles are defined these steps must be done to ensure the system is ready to use, this includes setting a default
|
||||
role, assigning a root (all permission) role that the server/system will use <span class="keyword">and</span> the linear order that the roles fall into:
|
||||
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>
|
||||
}
|
||||
|
||||
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>
|
||||
}
|
||||
|
||||
Just remember that <span class="keyword">in</span> this example all these roles have <span class="keyword">not</span> been defined; so make sure all your roles that are used are defined
|
||||
before hand; a config file on <span class="global">load</span> is useful <span class="keyword">for</span> this to ensure that its loaded before the first player even joins.</code></pre>
|
||||
<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 -->
|
||||
@@ -376,10 +371,10 @@
|
||||
<td class="name"><a href="#expcore.permission_groups">expcore.permission_groups</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name"><a href="#expcore.sudo">expcore.sudo</a></td>
|
||||
<td class="name"><a href="#expcore.async">expcore.async</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name"><a href="#resources.color_presets">resources.color_presets</a></td>
|
||||
<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>
|
||||
@@ -419,7 +414,7 @@
|
||||
<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>
|
||||
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>
|
||||
@@ -438,15 +433,15 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="name"><a href="#assign_player">assign_player(player, roles[, by_player_name=<server>][, silent=false])</a></td>
|
||||
<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>][, silent=false])</a></td>
|
||||
<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(roles)</a></td>
|
||||
<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>
|
||||
@@ -480,7 +475,7 @@
|
||||
<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>
|
||||
-- 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>
|
||||
@@ -565,16 +560,16 @@
|
||||
<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>
|
||||
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_promote_condition">Roles._prototype:set_auto_promote_condition(callback)</a></td>
|
||||
<td class="summary">Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will receive the role
|
||||
nb: this is one way, failing false after already gaining the role will not revoke the role</td>
|
||||
<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:set_block_auto_promote">Roles._prototype:set_block_auto_promote([state=true])</a></td>
|
||||
<td class="summary">Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment</td>
|
||||
<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>
|
||||
@@ -712,8 +707,8 @@
|
||||
<dt>
|
||||
<div class="divider divider-custom"></div>
|
||||
<div class="block section-item-header">
|
||||
<a href="#expcore.sudo" class="fragment-hashtag">#</a>
|
||||
<span class="section-item-title" id="expcore.sudo">expcore.sudo</span>
|
||||
<a href="#expcore.async" class="fragment-hashtag">#</a>
|
||||
<span class="section-item-title" id="expcore.async">expcore.async</span>
|
||||
</div>
|
||||
</dt>
|
||||
<dd>
|
||||
@@ -737,8 +732,8 @@
|
||||
<dt>
|
||||
<div class="divider divider-custom"></div>
|
||||
<div class="block section-item-header">
|
||||
<a href="#resources.color_presets" class="fragment-hashtag">#</a>
|
||||
<span class="section-item-title" id="resources.color_presets">resources.color_presets</span>
|
||||
<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>
|
||||
@@ -818,6 +813,9 @@
|
||||
<!-- 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>
|
||||
@@ -884,6 +882,9 @@
|
||||
<!-- 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>
|
||||
@@ -950,6 +951,9 @@
|
||||
<!-- 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>
|
||||
@@ -1016,6 +1020,9 @@
|
||||
<!-- 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>
|
||||
@@ -1073,6 +1080,9 @@
|
||||
<!-- 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>
|
||||
@@ -1130,6 +1140,9 @@
|
||||
<!-- 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>
|
||||
@@ -1144,7 +1157,7 @@
|
||||
<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>
|
||||
nb: this function is used for the input for most outward facing functions</p>
|
||||
<p class="section-item-description"></p>
|
||||
|
||||
<!-- parameters start -->
|
||||
@@ -1188,6 +1201,9 @@
|
||||
<!-- 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>
|
||||
@@ -1245,6 +1261,9 @@
|
||||
<!-- 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>
|
||||
@@ -1302,6 +1321,9 @@
|
||||
<!-- 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>
|
||||
@@ -1312,7 +1334,7 @@
|
||||
<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>][, silent=false])</span>
|
||||
<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>
|
||||
@@ -1379,6 +1401,23 @@
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
@@ -1405,6 +1444,11 @@
|
||||
<!-- 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>
|
||||
@@ -1412,7 +1456,7 @@
|
||||
<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>][, silent=false])</span>
|
||||
<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>
|
||||
@@ -1479,6 +1523,23 @@
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
@@ -1505,6 +1566,11 @@
|
||||
<!-- 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>
|
||||
@@ -1512,7 +1578,7 @@
|
||||
<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(roles)</span>
|
||||
<span class="section-item-title" id="override_player_roles">override_player_roles([player_name], roles)</span>
|
||||
</div>
|
||||
</dt>
|
||||
<dd>
|
||||
@@ -1530,6 +1596,23 @@
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
@@ -1555,6 +1638,14 @@
|
||||
<!-- 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>
|
||||
@@ -1631,6 +1722,9 @@
|
||||
<!-- 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>
|
||||
@@ -1704,6 +1798,9 @@
|
||||
<!-- 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>
|
||||
@@ -1777,6 +1874,9 @@
|
||||
<!-- 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>
|
||||
@@ -1794,7 +1894,7 @@
|
||||
<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>
|
||||
-- nb: function also re links parents due to expected position in the config file</p>
|
||||
<p class="section-item-description"></p>
|
||||
|
||||
<!-- parameters start -->
|
||||
@@ -1831,6 +1931,15 @@
|
||||
<!-- 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>
|
||||
@@ -1881,8 +1990,6 @@
|
||||
(<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
|
||||
flag param - player - the player that has had they roles changed
|
||||
flag param - state - the state of the flag, aka if the flag is present
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1899,6 +2006,11 @@
|
||||
<!-- see also end -->
|
||||
|
||||
<!-- usage start -->
|
||||
<strong>Usage:</strong>
|
||||
<pre class="code" data-lang="Lua"><code><span class="comment">-- Defineing 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>
|
||||
@@ -1949,6 +2061,9 @@
|
||||
<!-- 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>
|
||||
@@ -1999,6 +2114,9 @@
|
||||
<!-- 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>
|
||||
@@ -2073,6 +2191,9 @@
|
||||
<!-- see also end -->
|
||||
|
||||
<!-- usage start -->
|
||||
<strong>Usage:</strong>
|
||||
<pre class="code" data-lang="Lua"><code><span class="comment">-- Defineing 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>
|
||||
@@ -2134,6 +2255,9 @@
|
||||
<!-- 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>
|
||||
@@ -2191,6 +2315,12 @@
|
||||
<!-- 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>
|
||||
@@ -2248,6 +2378,12 @@
|
||||
<!-- see also end -->
|
||||
|
||||
<!-- usage start -->
|
||||
<strong>Usage:</strong>
|
||||
<pre class="code" data-lang="Lua"><code><span class="comment">-- Disalow 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>
|
||||
@@ -2305,6 +2441,9 @@
|
||||
<!-- 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>
|
||||
@@ -2382,6 +2521,9 @@
|
||||
<!-- 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>
|
||||
@@ -2416,6 +2558,9 @@
|
||||
<!-- 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>
|
||||
@@ -2473,6 +2618,9 @@
|
||||
<!-- 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>
|
||||
@@ -2533,6 +2681,9 @@
|
||||
<!-- 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>
|
||||
@@ -2590,6 +2741,9 @@
|
||||
<!-- 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>
|
||||
@@ -2664,6 +2818,9 @@
|
||||
<!-- 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>
|
||||
@@ -2678,7 +2835,7 @@
|
||||
<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>
|
||||
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 -->
|
||||
@@ -2722,21 +2879,24 @@
|
||||
<!-- 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_promote_condition" class="fragment-hashtag">#</a>
|
||||
<span class="section-item-title" id="Roles._prototype:set_auto_promote_condition">Roles._prototype:set_auto_promote_condition(callback)</span>
|
||||
<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 promote condition that is checked every 5 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-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 -->
|
||||
@@ -2780,6 +2940,11 @@
|
||||
<!-- 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>
|
||||
@@ -2793,7 +2958,7 @@
|
||||
<dd>
|
||||
<div class="section-item-body">
|
||||
|
||||
<p class="section-item-summary">Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment</p>
|
||||
<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 -->
|
||||
@@ -2813,7 +2978,7 @@
|
||||
|
||||
(<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 promoted
|
||||
when true the players with this role will not be auto assigned to other roles
|
||||
|
||||
(<em>default</em>: true)
|
||||
</li>
|
||||
@@ -2838,6 +3003,9 @@
|
||||
<!-- 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_promote()</code></pre>
|
||||
<!-- usage end -->
|
||||
|
||||
</dd>
|
||||
@@ -2930,6 +3098,9 @@
|
||||
<!-- 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>
|
||||
@@ -3019,6 +3190,9 @@
|
||||
<!-- 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>
|
||||
@@ -3077,6 +3251,11 @@
|
||||
<!-- 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>
|
||||
@@ -3134,6 +3313,9 @@
|
||||
<!-- 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>
|
||||
@@ -3152,7 +3334,7 @@
|
||||
<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 2019-10-25 23:42:24 UTC</i>
|
||||
<i>Last updated 2020-03-31 23:28:20 UTC</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user