Factorio role system to manage custom permissions
[[
| Roles._prototype:add_player (player, skip_check, skip_event) | Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign |
| Roles._prototype:allow (actions) | Sets the allow actions for this role, actions in this list will be allowed for this role |
| Roles._prototype:clear_flags () | Clears all flags from this role, individual flags can be removed with set_flag(name,false) |
| Roles._prototype:disallow (actions) | Sets the disallow actions for this role, will prevent actions from being allowed regardless of inheritance |
| Roles._prototype:get_players ([online=nil]) | Returns an array of all the players who have this role, can be filtered by online status |
| Roles._prototype:has_flag (name) | A test for if the role has a flag set |
| Roles._prototype:is_allowed (action) | Test for if a role is allowed the given action, mostly internal see Roles.player_allowed |
| Roles._prototype:print (message) | Will print a message to all players with this role |
| Roles._prototype:remove_player (player, skip_check, skip_event) | Removes a player from this role, players can have more than one role at a time, used internally see Roles.unassign |
| Roles._prototype:set_allow_all ([state=true]) | Sets the default allow state of the role, true will allow all actions |
| Roles._prototype:set_auto_promote_condition (callback) | Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role nb: this is one way, failing false after already gaining the role will not revoke the role |
| Roles._prototype:set_block_auto_promote ([state=true]) | Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment |
| Roles._prototype:set_custom_color (color) | Sets a custom colour for the role, can be accessed by other code |
| Roles._prototype:set_custom_tag (tag) | Sets a custom player tag for the role, can be accessed by other code |
| Roles._prototype:set_flag (name[, value=true]) | Sets the state of a flag for a role, flags can be used to apply effects to players |
| Roles._prototype:set_parent (role) | 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 |
| Roles._prototype:set_permission_group (name[, use_factorio_api=false]) | Sets the permission group for this role, players will be moved to the group of they highest role |
| Roles.assign_player (player, roles[, by_player_name= |
Gives a player the given role(s) with an option to pass a by player name used in the log |
| Roles.debug () | Returns a string which contains all roles in index order displaying all data for them |
| Roles.define_flag_trigger (name, callback) | Defines a new trigger for when a tag is added or removed from a player |
| Roles.define_role_order (order) | 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 |
| Roles.get_player_highest_role (player) | Gets the highest role which the player has, can be used to compeer one player to another |
| Roles.get_player_roles (player) | Gets all the roles of the given player, this will always contain the default role |
| Roles.get_role_by_name (name) | Get a role for the given name |
| Roles.get_role_by_order (index) | Get a role with the given order index |
| Roles.get_role_from_any (any) | 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 |
| Roles.new_role (name[, short_hand=name]) | Defines a new role and returns the prototype to allow configuration |
| Roles.override_player_roles (roles) | Overrides all player roles with the given table of roles, useful to mass set roles on game start |
| Roles.player_allowed (player, action) | A test for weather a player has at least one role which is allowed the given action |
| Roles.player_has_flag (player, flag_name) | A test for weather a player has the given flag true for at least one of they roles |
| Roles.player_has_role (player, search_role) | A test for weather a player has the given role |
| Roles.print_to_roles (roles, message) | Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam |
| Roles.print_to_roles_higher (role, message) | Prints a message to all players who have the given role or one which is higher (excluding default) |
| Roles.print_to_roles_lower (role, message) | Prints a message to all players who have the given role or one which is lower (excluding default) |
| Roles.set_default (name) | Sets the default role which every player will have, this needs to be called at least once |
| Roles.set_root (name) | Sets the root role which will always have all permissions, any server actions act from this role |
| Roles.unassign_player (player, roles[, by_player_name= |
Removes a player from the given role(s) with an option to pass a by player name used in the log |
Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign
Parameters:Sets the allow actions for this role, actions in this list will be allowed for this role
Parameters:Clears all flags from this role, individual flags can be removed with set_flag(name,false)
Returns:Sets the disallow actions for this role, will prevent actions from being allowed regardless of inheritance
Parameters:Returns an array of all the players who have this role, can be filtered by online status
Parameters:A test for if the role has a flag set
Parameters:Test for if a role is allowed the given action, mostly internal see Roles.player_allowed
Parameters:Will print a message to all players with this role
Parameters:Removes a player from this role, players can have more than one role at a time, used internally see Roles.unassign
Parameters:Sets the default allow state of the role, true will allow all actions
Parameters:Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role nb: this is one way, failing false after already gaining the role will not revoke the role
Parameters:Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment
Parameters:Sets a custom colour for the role, can be accessed by other code
Parameters:Sets a custom player tag for the role, can be accessed by other code
Parameters:Sets the state of a flag for a role, flags can be used to apply effects to players
Parameters: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
Parameters:Sets the permission group for this role, players will be moved to the group of they highest role
Parameters:Gives a player the given role(s) with an option to pass a by player name used in the log
Parameters:Returns a string which contains all roles in index order displaying all data for them
Returns:Defines a new trigger for when a tag is added or removed from a player
Parameters: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
Parameters:Gets the highest role which the player has, can be used to compeer one player to another
Parameters:Gets all the roles of the given player, this will always contain the default role
Parameters:Get a role for the given name
Parameters:Get a role with the given order index
Parameters: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
Parameters: Returns:Defines a new role and returns the prototype to allow configuration
Parameters:Overrides all player roles with the given table of roles, useful to mass set roles on game start
Parameters:A test for weather a player has at least one role which is allowed the given action
Parameters:A test for weather a player has the given flag true for at least one of they roles
Parameters:A test for weather a player has the given role
Parameters:Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam
Parameters:Prints a message to all players who have the given role or one which is higher (excluding default)
Parameters:Prints a message to all players who have the given role or one which is lower (excluding default)
Parameters:Sets the default role which every player will have, this needs to be called at least once
Parameters:Sets the root role which will always have all permissions, any server actions act from this role
Parameters:Removes a player from the given role(s) with an option to pass a by player name used in the log
Parameters: