Added report commands

This commit is contained in:
Cooldude2606
2019-04-18 15:16:12 +01:00
parent 2c108e6792
commit 17e61e710b
4 changed files with 124 additions and 0 deletions

View File

@@ -108,6 +108,10 @@
>>>>Functions List (see function for more detail):
Roles.debug() --- Returns a string which contains all roles in index order displaying all data for them
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.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)
@@ -240,6 +244,46 @@ function Roles.debug()
return output
end
--- Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam
-- @tparam roles table a table of roles which to send the message to
-- @tparam message string the message to send to the players
function Roles.print_to_roles(roles,message)
for _,role in pairs(roles) do
role = Roles.get_role_from_any(role)
if role then role:print(message) end
end
end
--- Prints a message to all players who have the given role or one which is higher (excluding default)
-- @tparam role string the name of the role to send the message to
-- @tparam message string the message to send to the players
function Roles.print_to_roles_higher(role,message)
role = Roles.get_role_from_any(role)
if not role then return end
local roles = {}
for index,role_name in pairs(Roles.config.order) do
if index <= role.index and role_name ~= Roles.config.internal.default then
table.insert(roles,role_name)
end
end
Roles.print_to_roles(roles,message)
end
--- Prints a message to all players who have the given role or one which is lower (excluding default)
-- @tparam role string the name of the role to send the message to
-- @tparam message string the message to send to the players
function Roles.print_to_roles_lower(role,message)
role = Roles.get_role_from_any(role)
if not role then return end
local roles = {}
for index,role_name in pairs(Roles.config.order) do
if index >= role.index and role_name ~= Roles.config.internal.default then
table.insert(roles,role_name)
end
end
Roles.print_to_roles(roles,message)
end
--- Get a role for the given name
-- @tparam name string the name of the role to get
-- @treturn Roles._prototype the role with that name or nil