mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-11 23:54:52 +09:00
Merge branch 'release/5.4.0'
This commit is contained in:
commit
4c5c693202
103 files changed
+2094
-153
No files matched your search
@@ -83,3 +83,6 @@ $RECYCLE.BIN/
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
.vscode
|
||||
*luacheckrc
|
||||
+1002
File diff suppressed because it is too large.
Load diff
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"cSpell.enabledLanguageIds": [
|
||||
"asciidoc",
|
||||
"c",
|
||||
"cpp",
|
||||
"csharp",
|
||||
"css",
|
||||
"go",
|
||||
"handlebars",
|
||||
"html",
|
||||
"jade",
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"json",
|
||||
"latex",
|
||||
"less",
|
||||
"lua",
|
||||
"markdown",
|
||||
"php",
|
||||
"plaintext",
|
||||
"pub",
|
||||
"python",
|
||||
"restructuredtext",
|
||||
"rust",
|
||||
"scss",
|
||||
"text",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"yml"
|
||||
]
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
--- Desction <get from json>
|
||||
-- @module ThisModule@X.Y.Z
|
||||
-- @author <get from json>
|
||||
-- @license <get from json>
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Module = require('Module')
|
||||
local SubModule = require('Collection.Submodule')
|
||||
local OptModule -- OptModule@^X.Y.Z
|
||||
|
||||
-- Local Variables
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function(self)
|
||||
if loaded_modules['OptModule'] then OptModule = require('OptModule') end
|
||||
if loaded_modules['OptModule2'] then require(module_path..'/src/module2',{self=self}) end
|
||||
--code
|
||||
end,
|
||||
on_post=function()
|
||||
--code
|
||||
end
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = global{
|
||||
key='value'
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
|
||||
-- Event Handlers Define
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -22,7 +22,10 @@
|
||||
</p>
|
||||
<h2 align="center">ExpGaming Scenario Repository</h2>
|
||||
|
||||
<p align="center"><font size="-2">Out Dated; Will be updated in the future</font></p>
|
||||
|
||||
#### Use and Installation
|
||||
|
||||
* Download the git repo
|
||||
* Move files into the scenario folder (C:\Users\User\AppData\Roaming\Factorio\scenarios\ExpGamingScenario)
|
||||
* Make edits to role and group configs as well as any other configs that you want
|
||||
@@ -30,9 +33,11 @@
|
||||
* All modules will be loaded if you have not removed any, any problems see log file
|
||||
|
||||
#### Creation of new modules
|
||||
|
||||
* Please see [FactorioSoftmodManager](https://github.com/explosivegaming/FactorioSoftmodManager) for making new modules
|
||||
|
||||
#### Forks and Pull Requests
|
||||
|
||||
* We are happy for people to make pull requests if you wish to help make our server better
|
||||
* Your server is a community server, it is all about the people and feedback is good
|
||||
* Dont be afraid to make a pull request as if it fixes something then its a good change
|
||||
@@ -1,3 +0,0 @@
|
||||
new_type('command','Commands',false,'param')
|
||||
new_type('event','Events',false,'field')
|
||||
new_type('gui','Guis')
|
||||
@@ -6,8 +6,13 @@ require 'config.command_parse_general'
|
||||
|
||||
Commands.add_parse('role',function(input,player,reject)
|
||||
if not input then return end
|
||||
local roles = Roles.config.roles
|
||||
local role = auto_complete(roles,input,true)
|
||||
local roles = Roles.config.order
|
||||
local rev_roles = {}
|
||||
for i=#roles,1,-1 do
|
||||
table.insert(rev_roles,roles[i])
|
||||
end
|
||||
local role = auto_complete(rev_roles,input)
|
||||
role = Roles.get_role_by_name(role)
|
||||
if not role then
|
||||
return reject{'expcore-role.reject-role'}
|
||||
else
|
||||
|
||||
@@ -16,6 +16,12 @@ return {
|
||||
'modules.commands.help',
|
||||
'modules.commands.roles',
|
||||
'modules.commands.rainbow',
|
||||
'modules.commands.clear-inventory',
|
||||
'modules.commands.jail',
|
||||
'modules.commands.repair',
|
||||
'modules.commands.reports',
|
||||
'modules.commands.spawn',
|
||||
'modules.commands.warnings',
|
||||
-- QoL Addons
|
||||
'modules.addons.chat-popups',
|
||||
'modules.addons.damage-popups',
|
||||
@@ -25,6 +31,7 @@ return {
|
||||
'modules.addons.compilatron',
|
||||
'modules.addons.scorched-earth',
|
||||
'modules.addons.pollution-grading',
|
||||
'modules.addons.random-player-colours',
|
||||
-- Config Files
|
||||
'config.command_auth_admin', -- commands tagged with admin_only are blocked for non admins
|
||||
'config.command_auth_roles', -- commands must be allowed via the role config
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
return {
|
||||
players={
|
||||
BADgamerNL={r=255,g=20,b=147},
|
||||
arty714={r=150,g=68,b=161},
|
||||
Cooldude2606={r=57,g=192,b=207},
|
||||
mark9064={r=99,g=0,b=255},
|
||||
eissturm={r=25,g=25,b=112},
|
||||
Sakama={r=20,g=213,b=80},
|
||||
Sakama={r=20,g=213,b=80},
|
||||
freek18={r=50,g=0,b=255},
|
||||
aldldl={r=0,g=131,b=255},
|
||||
NAD4X4={r=135,g=206,b=250},
|
||||
cydes={r=82,g=249,b=155},
|
||||
UUBlueFire={r=0,g=204,b=255}
|
||||
},
|
||||
disallow = { -- the value does not matter it is only the key which is checked
|
||||
black = {r = 0, g = 0, b = 0},
|
||||
white = {r = 255, g = 255, b = 255},
|
||||
jailed = {r = 255, g = 255, b = 255},
|
||||
probation = {r = 255, g = 255, b = 255},
|
||||
guest = {r = 255, g = 255, b = 255},
|
||||
auto_trusted = {r = 192, g = 192, b = 192},
|
||||
regular = {r = 0.155, g = 0.540, b = 0.898},
|
||||
admin = {r = 0.093, g = 0.768, b = 0.172},
|
||||
donator = {r = 172.6, g = 70.2, b = 215.8},
|
||||
[-10] = {r = 255, g = 255, b = 255},
|
||||
[0] = {r = 255, g = 255, b = 255},
|
||||
[10] = {r = 192, g = 192, b = 192},
|
||||
[20] = {r = 0.155, g = 0.540, b = 0.898},
|
||||
[30] = {r = 0.093, g = 0.768, b = 0.172},
|
||||
success = {r = 0, g = 255, b = 0},
|
||||
warning = {r = 255, g = 255, b = 0},
|
||||
fail = {r = 255, g = 0, b = 0},
|
||||
info = {r = 255, g = 255, b = 255}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
return {
|
||||
disallow = {
|
||||
['loader']=true,
|
||||
['fast-loader']=true,
|
||||
['express-loader']=true,
|
||||
['electric-energy-interface']=true,
|
||||
['infinity-chest']=true
|
||||
},
|
||||
max_range=50,
|
||||
allow_blueprint_repair=false,
|
||||
allow_ghost_revive=true,
|
||||
allow_heal_entities=true
|
||||
}
|
||||
+34
-12
@@ -33,12 +33,14 @@ Roles.new_role('System','SYS')
|
||||
:set_permission_group('Admin')
|
||||
:set_flag('is_admin')
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_allow_all()
|
||||
|
||||
Roles.new_role('Senior Administrator','SAdmin')
|
||||
:set_permission_group('Admin')
|
||||
:set_flag('is_admin')
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_parent('Administrator')
|
||||
:allow{
|
||||
'command/interface',
|
||||
@@ -50,6 +52,7 @@ Roles.new_role('Administrator','Admin')
|
||||
:set_custom_color{r=233,g=63,b=233}
|
||||
:set_flag('is_admin')
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_parent('Moderator')
|
||||
:allow{
|
||||
}
|
||||
@@ -59,10 +62,19 @@ Roles.new_role('Moderator','Mod')
|
||||
:set_custom_color{r=0,g=170,b=0}
|
||||
:set_flag('is_admin')
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_parent('Trainee')
|
||||
:allow{
|
||||
'command/assign-role',
|
||||
'command/unassign-role'
|
||||
'command/unassign-role',
|
||||
'command/repair',
|
||||
'command/kill/always',
|
||||
'command/tag-clear/always',
|
||||
'command/go-to-spawn/always',
|
||||
'command/clear-reports',
|
||||
'command/clear-warnings',
|
||||
'command/clear-temp-ban',
|
||||
'command/clear-inventory',
|
||||
}
|
||||
|
||||
Roles.new_role('Trainee','TrMod')
|
||||
@@ -70,14 +82,17 @@ Roles.new_role('Trainee','TrMod')
|
||||
:set_custom_color{r=0,g=170,b=0}
|
||||
:set_flag('is_admin')
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_parent('Donator')
|
||||
:allow{
|
||||
'command/admin-chat',
|
||||
'command/teleport',
|
||||
'command/bring',
|
||||
'command/goto',
|
||||
'command/kill/always',
|
||||
'command/tag-clear/always',
|
||||
'command/temp-ban',
|
||||
'command/give-warning',
|
||||
'command/get-warnings',
|
||||
'command/get-reports',
|
||||
}
|
||||
|
||||
--- Trusted Roles
|
||||
@@ -85,6 +100,7 @@ Roles.new_role('Sponsor','Spon')
|
||||
:set_permission_group('Trusted')
|
||||
:set_custom_color{r=247,g=246,b=54}
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_parent('Pay to Win')
|
||||
:allow{
|
||||
}
|
||||
@@ -93,6 +109,7 @@ Roles.new_role('Pay to Win','P2W')
|
||||
:set_permission_group('Trusted')
|
||||
:set_custom_color{r=238,g=172,b=44}
|
||||
:set_flag('is_spectator')
|
||||
:set_flag('report-immune')
|
||||
:set_parent('Donator')
|
||||
:allow{
|
||||
}
|
||||
@@ -103,6 +120,8 @@ Roles.new_role('Donator','Don')
|
||||
:set_flag('is_spectator')
|
||||
:set_parent('Veteran')
|
||||
:allow{
|
||||
'command/jail',
|
||||
'command/unjail'
|
||||
}
|
||||
|
||||
Roles.new_role('Partner','Part')
|
||||
@@ -111,6 +130,8 @@ Roles.new_role('Partner','Part')
|
||||
:set_flag('is_spectator')
|
||||
:set_parent('Veteran')
|
||||
:allow{
|
||||
'command/jail',
|
||||
'command/unjail'
|
||||
}
|
||||
|
||||
Roles.new_role('Veteran','Vet')
|
||||
@@ -138,7 +159,10 @@ Roles.new_role('Regular','Reg')
|
||||
:set_custom_color{r=79,g=155,b=163}
|
||||
:set_parent('Guest')
|
||||
:allow{
|
||||
'command/kill'
|
||||
'command/kill',
|
||||
'command/rainbow',
|
||||
'command/go-to-spawn',
|
||||
'command/me',
|
||||
}
|
||||
:set_auto_promote_condition(function(player)
|
||||
if player.online_time > 3*216000 then
|
||||
@@ -147,16 +171,15 @@ Roles.new_role('Regular','Reg')
|
||||
end)
|
||||
|
||||
--- Guest/Default role
|
||||
Roles.new_role('Guest','')
|
||||
local default = Roles.new_role('Guest','')
|
||||
:set_permission_group('Guest')
|
||||
:set_custom_color{r=185,g=187,b=160}
|
||||
:allow{
|
||||
'command/me',
|
||||
'command/tag',
|
||||
'command/tag-clear',
|
||||
'command/chelp',
|
||||
'command/list-roles',
|
||||
'command/rainbow'
|
||||
'command/report',
|
||||
}
|
||||
|
||||
--- Jail role
|
||||
@@ -164,15 +187,14 @@ Roles.new_role('Jail')
|
||||
:set_permission_group('Restricted')
|
||||
:set_custom_color{r=50,g=50,b=50}
|
||||
:set_block_auto_promote(true)
|
||||
:allow{
|
||||
}
|
||||
:disallow(default.allowed)
|
||||
|
||||
--- System defaults which are required to be set
|
||||
Roles.set_root('System')
|
||||
Roles.set_default('Guest')
|
||||
|
||||
Roles.define_role_order{
|
||||
'System',
|
||||
'System', -- Best to keep root at top
|
||||
'Senior Administrator',
|
||||
'Administrator',
|
||||
'Moderator',
|
||||
@@ -184,8 +206,8 @@ Roles.define_role_order{
|
||||
'Veteran',
|
||||
'Member',
|
||||
'Regular',
|
||||
'Guest',
|
||||
'Jail'
|
||||
'Jail',
|
||||
'Guest' -- Default must be last if you want to apply restrictions to other roles
|
||||
}
|
||||
|
||||
Roles.override_player_roles{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
--- Config file for the warning system, this is very similar to reports but is for the use of moderators rather than normal users.
|
||||
return {
|
||||
actions = { -- what actions are taking at number of warnings
|
||||
-- if a localized string is used then __1__ will by_player_name and __2__ will be the current warning count (auto inserted)
|
||||
{'warnings.received'},
|
||||
{'warnings.received'},
|
||||
{'warnings.received',{'warnings.pre-kick'}},
|
||||
function(player,by_player_name,number_of_warnings)
|
||||
game.kick_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.kick'}})
|
||||
end,
|
||||
{'warnings.received',{'warnings.pre-pre-ban'}},
|
||||
{'warnings.received',{'warnings.pre-ban'}},
|
||||
function(player,by_player_name,number_of_warnings)
|
||||
game.ban_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.ban',{'info.website-link'}}})
|
||||
end
|
||||
},
|
||||
temp_warning_cool_down=30, -- time for a temp warning (given by script) to be removed (in minutes)
|
||||
temp_warning_limit=5 -- the number of temp warnings (given by script) that are allowed before full warnings are given
|
||||
}
|
||||
@@ -201,7 +201,7 @@
|
||||
Commands.remove_parse(name) --- Removes a parse function, see add_parse for adding them
|
||||
Commands.parse(name,input,player,reject,...) --- Intended to be used within other parse functions, runs a parse and returns success and new value
|
||||
|
||||
Commands.add_command(name,help) --- Creates a new command object to added details to, note this does not register the command to the game
|
||||
Commands.new_command(name,help) --- Creates a new command object to added details to, note this does not register the command to the game
|
||||
Commands._prototype:add_param(name,optional,parse,...) --- Adds a new param to the command this will be displayed in the help and used to parse the input
|
||||
Commands._prototype:set_defaults(defaults) --- Adds default values to params only matters if the param is optional
|
||||
Commands._prototype:set_flag(name,value) --- Adds a tag to the command which is passed via the flags param to the authenticators, can be used to assign command roles or type
|
||||
@@ -724,10 +724,10 @@ function Commands.run_command(command_event)
|
||||
|
||||
-- runs the command
|
||||
-- player: LuaPlayer, ... command params, raw: string
|
||||
table.insert(params,input_string)
|
||||
table.insert(params,command_data.max_param_count+1,input_string)
|
||||
local success, err = pcall(command_data.callback,player,unpack(params))
|
||||
if Commands.internal_error(success,command_data.name,err) then
|
||||
return command_log(player,command_data,'Internal Error: Command Callback Fail',params,command_event.parameter,err)
|
||||
return command_log(player,command_data,'Internal Error: Command Callback Fail',raw_params,command_event.parameter,err)
|
||||
end
|
||||
if err == Commands.defines.error or err == Commands.error then
|
||||
return command_log(player,command_data,'Custom Error',raw_params,input_string)
|
||||
|
||||
+31
-2
@@ -230,7 +230,7 @@ end
|
||||
function Public.move_items(items,surface,position,radius,chest_type)
|
||||
chest_type = chest_type or 'iron-chest'
|
||||
surface = surface or game.surfaces[1]
|
||||
if type(position) ~= 'table' then return end
|
||||
if position and type(position) ~= 'table' then return end
|
||||
if type(items) ~= 'table' then return end
|
||||
-- Finds all entities of the given type
|
||||
local p = position or {x=0,y=0}
|
||||
@@ -438,7 +438,7 @@ end
|
||||
-- @return the list item found that matches the input
|
||||
function Public.auto_complete(options,input,use_key,rtn_key)
|
||||
local rtn = {}
|
||||
if type(input)~= 'string' then return end
|
||||
if type(input) ~= 'string' then return end
|
||||
input = input:lower()
|
||||
for key,value in pairs(options) do
|
||||
local check = use_key and key or value
|
||||
@@ -497,10 +497,39 @@ function Public.table_keysort(tbl)
|
||||
return _tbl
|
||||
end
|
||||
|
||||
--- Returns a message with valid chat tags to change its colour
|
||||
-- @tparam message string the message that will be in the output
|
||||
-- @tparam color table a color which contains r,g,b as its keys
|
||||
-- @treturn string the message with the color tags included
|
||||
function Public.format_chat_colour(message,color)
|
||||
color = color or Colours.white
|
||||
local color_tag = '[color='..math.round(color.r,3)..','..math.round(color.g,3)..','..math.round(color.b,3)..']'
|
||||
return string.format('%s%s[/color]',color_tag,message)
|
||||
end
|
||||
|
||||
--- Returns a message with valid chat tags to change its colour, using localization
|
||||
-- @tparam message ?string|table the message that will be in the output
|
||||
-- @tparam color table a color which contains r,g,b as its keys
|
||||
-- @treturn table the message with the color tags included
|
||||
function Public.format_chat_colour_localized(message,color)
|
||||
color = color or Colours.white
|
||||
color = math.round(color.r,3)..','..math.round(color.g,3)..','..math.round(color.b,3)
|
||||
return {'color-tag',color,message}
|
||||
end
|
||||
|
||||
--- Returns the players name in the players color
|
||||
-- @tparam player LuaPlayer the player to use the name and color of
|
||||
-- @tparam[opt=false] raw_string boolean when true a string is returned rather than a localized string
|
||||
-- @treturn table the players name with tags for the players color
|
||||
function Public.format_chat_player_name(player,raw_string)
|
||||
player = Game.get_player_from_any(player)
|
||||
local player_name = player and player.name or '<Server>'
|
||||
local player_chat_colour = player and player.chat_color or Colours.white
|
||||
if raw_string then
|
||||
return Public.format_chat_colour(player_name,player_chat_colour)
|
||||
else
|
||||
return Public.format_chat_colour_localized(player_name,player_chat_colour)
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
||||
+84
-22
@@ -108,14 +108,18 @@
|
||||
>>>>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)
|
||||
Roles.get_player_roles(player) --- Gets all the roles of the given player, this will always contain the default role
|
||||
Roles.get_player_highest_role(player) --- Gets the highest role which the player has, can be used to compeer one player to another
|
||||
|
||||
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.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
|
||||
Roles.assign_player(player,roles,by_player_name,silent) --- Gives a player the given role(s) with an option to pass a by player name used in the log
|
||||
Roles.unassign_player(player,roles,by_player_name,silent) --- Removes a player from the given role(s) with an option to pass a by player name used in the log
|
||||
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_has_role(player,search_role) --- A test for weather a player has the given role
|
||||
@@ -170,15 +174,31 @@ local Roles = {
|
||||
_prototype={}
|
||||
}
|
||||
|
||||
--- When global is loaded it will have the metatable re-assigned to the roles
|
||||
Global.register(Roles.config,function(tbl)
|
||||
Roles.config = tbl
|
||||
for _,role in pairs(Roles.config.roles) do
|
||||
setmetatable(role,{__index=Roles._prototype})
|
||||
local parent = Roles.config.roles[role.parent]
|
||||
if parent then
|
||||
setmetatable(role.allowed_actions, {__index=parent.allowed_actions})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--- Internal function used to trigger a few different things when roles are changed
|
||||
local function emit_player_roles_updated(player,type,roles,by_player_name)
|
||||
-- this is the raw internal trigger as the other function is called at other times
|
||||
-- there is a second half called role_update which triggers after the event call, it also is called when a player joins
|
||||
local function emit_player_roles_updated(player,type,roles,by_player_name,skip_game_print)
|
||||
by_player_name = game.player and game.player.name or by_player_name or '<server>'
|
||||
local by_player = Game.get_player_from_any(by_player_name)
|
||||
local by_player_index = by_player and by_player.index or 0
|
||||
-- get the event id from the type of emit
|
||||
local event = Roles.player_role_assigned
|
||||
if type == 'unassign' then
|
||||
event = Roles.player_role_unassigned
|
||||
end
|
||||
local by_player = Game.get_player_from_any(by_player_name)
|
||||
local by_player_index = by_player and by_player.index or 0
|
||||
-- convert the roles to objects and get the names of the roles
|
||||
local role_names = {}
|
||||
for index,role in pairs(roles) do
|
||||
role = Roles.get_role_from_any(role)
|
||||
@@ -187,7 +207,15 @@ local function emit_player_roles_updated(player,type,roles,by_player_name)
|
||||
table.insert(role_names,role.name)
|
||||
end
|
||||
end
|
||||
game.print({'expcore-roles.game-message-'..type,player.name,table.concat(role_names,', '),by_player_name},Colours.cyan)
|
||||
-- output to all the different locations: game print, player sound, event trigger and role log
|
||||
if not skip_game_print then
|
||||
game.print({'expcore-roles.game-message-'..type,player.name,table.concat(role_names,', '),by_player_name},Colours.cyan)
|
||||
end
|
||||
if type == 'assign' then
|
||||
player.play_sound{path='utility/achievement_unlocked'}
|
||||
else
|
||||
player.play_sound{path='utility/game_lost'}
|
||||
end
|
||||
script.raise_event(event,{
|
||||
name=Roles.player_roles_updated,
|
||||
tick=game.tick,
|
||||
@@ -203,18 +231,6 @@ local function emit_player_roles_updated(player,type,roles,by_player_name)
|
||||
}..'\n',true,0)
|
||||
end
|
||||
|
||||
--- When global is loaded it will have the metatable re-assigned to the roles
|
||||
Global.register(Roles.config,function(tbl)
|
||||
Roles.config = tbl
|
||||
for _,role in pairs(Roles.config.roles) do
|
||||
setmetatable(role,{__index=Roles._prototype})
|
||||
local parent = Roles.config.roles[role.parent]
|
||||
if parent then
|
||||
setmetatable(role.allowed_actions, {__index=parent.allowed_actions})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--- Returns a string which contains all roles in index order displaying all data for them
|
||||
-- @treturn string the debug output string
|
||||
function Roles.debug()
|
||||
@@ -228,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
|
||||
@@ -293,7 +349,8 @@ end
|
||||
-- @tparam player LuaPlayer the player that will be assigned the roles
|
||||
-- @tparam role table a table of roles that the player will be given, can be one role and can be role names
|
||||
-- @tparam[opt=<server>] by_player_name string the name of the player that will be shown in the log
|
||||
function Roles.assign_player(player,roles,by_player_name)
|
||||
-- @tparam[opt=false] silent boolean when true there will be no game message printed
|
||||
function Roles.assign_player(player,roles,by_player_name,silent)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
if type(roles) ~= 'table' or roles.name then
|
||||
@@ -305,14 +362,15 @@ function Roles.assign_player(player,roles,by_player_name)
|
||||
role:add_player(player,false,true)
|
||||
end
|
||||
end
|
||||
emit_player_roles_updated(player,'assign',roles,by_player_name)
|
||||
emit_player_roles_updated(player,'assign',roles,by_player_name,silent)
|
||||
end
|
||||
|
||||
--- Removes a player from the given role(s) with an option to pass a by player name used in the log
|
||||
-- @tparam player LuaPlayer the player that will have the roles removed
|
||||
-- @tparam roles table a table of roles to be removed from the player, can be one role and can be role names
|
||||
-- @tparam[opt=<server>] by_player_name string the name of the player that will be shown in the logs
|
||||
function Roles.unassign_player(player,roles,by_player_name)
|
||||
-- @tparam[opt=false] silent boolean when true there will be no game message printed
|
||||
function Roles.unassign_player(player,roles,by_player_name,silent)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
if type(roles) ~= 'table' or roles.name then
|
||||
@@ -324,7 +382,7 @@ function Roles.unassign_player(player,roles,by_player_name)
|
||||
role:remove_player(player,false,true)
|
||||
end
|
||||
end
|
||||
emit_player_roles_updated(player,'unassign',roles,by_player_name)
|
||||
emit_player_roles_updated(player,'unassign',roles,by_player_name,silent)
|
||||
end
|
||||
|
||||
--- Overrides all player roles with the given table of roles, useful to mass set roles on game start
|
||||
@@ -583,6 +641,8 @@ end
|
||||
-- @treturn boolean true if the player was added successfully
|
||||
function Roles._prototype:add_player(player,skip_check,skip_event)
|
||||
player = Game.get_player_from_any(player)
|
||||
-- Default role cant have players added or removed
|
||||
if self.name == Roles.config.internal.default then return end
|
||||
-- Check the player is valid, can be skipped but a name must be given
|
||||
if not player then
|
||||
if skip_check then
|
||||
@@ -615,6 +675,8 @@ end
|
||||
-- @treturn boolean true if the player was removed successfully
|
||||
function Roles._prototype:remove_player(player,skip_check,skip_event)
|
||||
player = Game.get_player_from_any(player)
|
||||
-- Default role cant have players added or removed
|
||||
if self.name == Roles.config.internal.default then return end
|
||||
-- Check the player is valid, can be skipped but a name must be given
|
||||
if not player then
|
||||
if skip_check then
|
||||
|
||||
+12
-1
@@ -25,4 +25,15 @@ custom-commands=We use custom commands, such as /tag and /me, use /chelp for mor
|
||||
read-readme=Make sure you have read the Readme (It can be found through the question mark on the top left)
|
||||
softmod=We run a softmod on our servers. A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
redmew=We dont talk about redmew here; they beat us to 1000 members ;-;
|
||||
lhd=All trains must be LHD! This is a long standing rule on our servers, please resepect this.
|
||||
lhd=All trains must be LHD! This is a long standing rule on our servers, please resepect this.
|
||||
|
||||
[warnings]
|
||||
received=You recived a warning from __1__. You have __2__ warnings. __3__
|
||||
pre-kick=This is your last warning before you are kicked.
|
||||
kick=You were kicked for having too many warnings; you may rejoy if you wish.
|
||||
pre-pre-ban=You are close to reciving a ban; successful ban appeals are unlikely.
|
||||
pre-ban=This your LAST warning before you are BANNED! successful ban appeals are unlikely.
|
||||
ban=You were banned for having too many warnings; Vist __1__ to request a ban appeal.
|
||||
script-warning=You are reciving script warnings; if you recive too many you will recive a permiment warning (__1__/__2__)
|
||||
script-wrning-removed=A script warning has expired (__1__/__2__)
|
||||
script-warning-limit=__1__ has recived a permiment warning from the script.
|
||||
+28
-4
@@ -1,6 +1,6 @@
|
||||
[exp-commands]
|
||||
kill-already-dead=You are already dead.
|
||||
admin-chat-format=[Admin Chat] [color=__3__]__1__[/color]: __2__
|
||||
admin-chat-format=[Admin Chat] __1__: __2__
|
||||
tp-no-position-found=No position to teleport to was found, please try again later.
|
||||
tp-to-self=Player can not be teleported to themselves.
|
||||
chelp-title=Help results for "__1__":
|
||||
@@ -9,6 +9,30 @@ chelp-format=/__1__ __2__ - __3__ __4__
|
||||
chelp-alias=Alias: __1__
|
||||
chelp-out-of-range=__1__ is an invalid page number.
|
||||
roles-higher-role=The role you tried to assign is higher than your highest.
|
||||
roles-list=All roles are: [color=__1__]__2__[/color]
|
||||
roles-list-player=[color=__1__]__2__[/color] has: [color=__3__]__4__[/color]
|
||||
roles-list-element=__1__, [color=__2__]__3__[/color]
|
||||
roles-list=All roles are: __1__
|
||||
roles-list-player=__1__ has: __2__
|
||||
roles-list-element=__1__, __2__
|
||||
jail-give=__1__ was jailed by __2__. Reason: __3__
|
||||
jail-remove=__1__ was unjailed by __2__.
|
||||
jail-already-jailed=__1__ is already in jail.
|
||||
jail-not-jailed=__1__ is not currently in jail.
|
||||
jail-temp-ban=__1__ was temp banned until next reset by __2__. Reason: __3__
|
||||
jail-temp-ban-clear=__1__ was cleared from temp banned by __2__.
|
||||
jail-not-temp-banned=__1__ is not currently temp banned.
|
||||
jail-already-banned=__1__ is already banned.
|
||||
report-player-immune=This player can not be reported.
|
||||
report-non-admin=__1__ was reported for __2__.
|
||||
report-admin=__1__ was reported by __2__ for __3__.
|
||||
report-already-reported=You can only report a player once, you can ask a moderator to clear this report.
|
||||
report-not-reported=The player had no reports on them.
|
||||
report-player-count-title=The following players have reports against them:
|
||||
report-player-report-title=__1__ has the following reports agasinst them:
|
||||
report-list=__1__: __2__
|
||||
report-removed=__1__ has one or more reports removed by __2__.
|
||||
warnings-received=__1__ recived a warning from __2__ for __3__.
|
||||
warnings-player=__1__ has __2__ warnings and __3__/__4__ script warnings.
|
||||
warnings-list-tilte=The following player have this many warnings (and this many script warnings):
|
||||
warnings-list=__1__: __2__ (__3__/__4__)
|
||||
warnings-cleared=__1__ had all they warnings cleared by __2__.
|
||||
spawn-unavailable=They was a problem getting you to spawn, please try again later.
|
||||
repair-result=__1__ entites were revived and __2__ were healed to max health.
|
||||
@@ -1,4 +1,5 @@
|
||||
time-symbol-days-short=__1__d
|
||||
color-tag=[color=__1__]__2__[/color]
|
||||
|
||||
[expcore-commands]
|
||||
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
||||
|
||||
@@ -7,20 +7,18 @@ local config = require 'config.compilatron'
|
||||
local messages = config.messages
|
||||
local locations = config.locations
|
||||
|
||||
local compilatrons = {}
|
||||
local current_messages = {}
|
||||
Global.register(
|
||||
{
|
||||
compilatrons = compilatrons,
|
||||
current_messages = current_messages
|
||||
},
|
||||
function(tbl)
|
||||
compilatrons = tbl.compilatrons
|
||||
current_messages = tbl.current_messages
|
||||
end
|
||||
)
|
||||
local Public = {
|
||||
compilatrons={},
|
||||
current_messages={}
|
||||
}
|
||||
|
||||
local Public = {}
|
||||
Global.register({
|
||||
Public.compilatrons,
|
||||
Public.current_messages
|
||||
},function(tbl)
|
||||
Public.compilatrons=tbl[1]
|
||||
Public.current_messages=tbl[2]
|
||||
end)
|
||||
|
||||
--- This will re-create the speech bubble after it de-spawns called with set_timeout
|
||||
local callback =
|
||||
@@ -33,17 +31,17 @@ local callback =
|
||||
ent.surface.create_entity(
|
||||
{name = 'compi-speech-bubble', text = messages[name][msg_number], position = {0, 0}, source = ent}
|
||||
)
|
||||
current_messages[name] = {message = message, msg_number = msg_number}
|
||||
Public.current_messages[name] = {message = message, msg_number = msg_number}
|
||||
end
|
||||
)
|
||||
|
||||
--- This will move the messages onto the next message in the loop
|
||||
local function circle_messages()
|
||||
for name, ent in pairs(compilatrons) do
|
||||
for name, ent in pairs(Public.compilatrons) do
|
||||
if not ent.valid then
|
||||
Public.spawn_compilatron(game.players[1].surface,name)
|
||||
end
|
||||
local current_message = current_messages[name]
|
||||
local current_message = Public.current_messages[name]
|
||||
local msg_number
|
||||
local message
|
||||
if current_message ~= nil then
|
||||
@@ -73,12 +71,12 @@ function Public.add_compilatron(entity, name)
|
||||
if name == nil then
|
||||
return
|
||||
end
|
||||
compilatrons[name] = entity
|
||||
Public.compilatrons[name] = entity
|
||||
local message =
|
||||
entity.surface.create_entity(
|
||||
{name = 'compi-speech-bubble', text = messages[name][1], position = {0, 0}, source = entity}
|
||||
)
|
||||
current_messages[name] = {message = message, msg_number = 1}
|
||||
Public.current_messages[name] = {message = message, msg_number = 1}
|
||||
end
|
||||
|
||||
--- This spawns a new compilatron on a surface with the given location tag (not a position)
|
||||
|
||||
@@ -94,6 +94,4 @@ if config.auto_collect_bodies then
|
||||
end
|
||||
|
||||
-- this is so other modules can access the logs
|
||||
return function()
|
||||
return deaths
|
||||
end
|
||||
return deaths
|
||||
@@ -0,0 +1,97 @@
|
||||
local Roles = require 'expcore.roles'
|
||||
local Game = require 'utils.game'
|
||||
local Global = require 'utils.global'
|
||||
local move_items = ext_require('expcore.common','move_items')
|
||||
|
||||
local Public = {
|
||||
old_roles = {},
|
||||
temp_bans = {},
|
||||
player_jailed=script.generate_event_name(),
|
||||
player_unjailed=script.generate_event_name(),
|
||||
player_temp_banned=script.generate_event_name(),
|
||||
player_clear_temp_ban=script.generate_event_name()
|
||||
}
|
||||
|
||||
Global.register({
|
||||
Public.old_roles,
|
||||
Public.temp_bans
|
||||
},function(tbl)
|
||||
Public.old_roles=tbl[1]
|
||||
Public.temp_bans=tbl[2]
|
||||
end)
|
||||
|
||||
local function event_emit(event,player,by_player_name,reason)
|
||||
script.raise_event(event,{
|
||||
name=event,
|
||||
tick=game.tick,
|
||||
player_index=player.index,
|
||||
by_player_name=by_player_name,
|
||||
reason=reason
|
||||
})
|
||||
end
|
||||
|
||||
--- Jails a player, this is only the logic there is no output to players
|
||||
-- @tparam player LuaPlayer the player that will be jailed, must not be in jail
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player doing the action used in logs
|
||||
-- @treturn the number of roles that were removed, nil if there was an error
|
||||
function Public.jail_player(player,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
if Roles.player_has_role(player,'Jail') then return end
|
||||
local old_roles = Roles.get_player_roles(player)
|
||||
Public.old_roles[player.name] = old_roles
|
||||
Roles.unassign_player(player,old_roles,by_player_name,true)
|
||||
Roles.assign_player(player,'Jail',by_player_name,true)
|
||||
event_emit(Public.player_jailed,player,by_player_name)
|
||||
return #old_roles
|
||||
end
|
||||
|
||||
--- Unjails a player, this is only the logic there is no output to players
|
||||
-- @tparam player LuaPlayer the player that will be unjailed, must be in jail
|
||||
-- @tparam[opt='<server>'] by_player_name string string the name of the player who is doing the action
|
||||
-- @treturn the number of roles that were added, nil if there was an error
|
||||
function Public.unjail_player(player,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
if not Roles.player_has_role(player,'Jail') then return end
|
||||
local old_roles = Public.old_roles[player.name]
|
||||
Roles.unassign_player(player,'Jail',by_player_name,true)
|
||||
Roles.assign_player(player,old_roles,by_player_name,true)
|
||||
event_emit(Public.player_unjailed,player,by_player_name)
|
||||
return #old_roles
|
||||
end
|
||||
|
||||
--- Temp bans a player which is similar to jail but will store the reason for the action and clears items
|
||||
-- @tparam player LuaPlayer the player that will be temp baned, must not be temp banned
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player that is doing the action
|
||||
-- @tparam[opt='None Given.'] reason string the reason that will be stored for this temp ban
|
||||
-- @treturn boolean true if successful else will return nil
|
||||
function Public.temp_ban_player(player,by_player_name,reason)
|
||||
player = Game.get_player_from_any(player)
|
||||
reason = reason or 'None Given.'
|
||||
if not player then return end
|
||||
if Public.temp_bans[player.name] then return end
|
||||
Public.jail_player(player,by_player_name)
|
||||
Public.temp_bans[player.name] = {reason,by_player_name}
|
||||
local inv = player.get_main_inventory()
|
||||
move_items(inv.get_contents())
|
||||
inv.clear()
|
||||
event_emit(Public.player_temp_banned,player,by_player_name,reason)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Removes temp ban from a player, note this does not restore the items
|
||||
-- @tparam player LuaPlayer the player that will be cleared from temp baned, must be temp banned
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player that is doing the action
|
||||
-- @treturn boolean true if successful else will return nil
|
||||
function Public.clear_temp_ban_player(player,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
if not Public.temp_bans[player.name] then return end
|
||||
Public.unjail_player(player,by_player_name)
|
||||
Public.temp_bans[player.name] = nil
|
||||
event_emit(Public.player_clear_temp_ban,player,by_player_name)
|
||||
return true
|
||||
end
|
||||
|
||||
return Public
|
||||
@@ -0,0 +1,28 @@
|
||||
local Colours = require 'resources.color_presets'
|
||||
local Game = require 'utils.game'
|
||||
local Event = require 'utils.event'
|
||||
local config = require 'config.preset_player_colours'
|
||||
local Global = require 'utils.global'
|
||||
require 'utils.table'
|
||||
|
||||
Global.register(config,function(tbl)
|
||||
config = tbl
|
||||
end)
|
||||
|
||||
local white = Colours.white
|
||||
local black = Colours.black
|
||||
Event.add(defines.events.on_player_created,function(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local color = 'white'
|
||||
if config.players[player.name] then
|
||||
color = config.players[player.name]
|
||||
else
|
||||
while not config.disallow[color] do
|
||||
color = table.get_random_dictionary_entry(Colours,true)
|
||||
end
|
||||
color = Colours[color]
|
||||
end
|
||||
color = {r=color.r/255,g=color.g/255,b=color.b/255,a=0.5}
|
||||
player.color = color
|
||||
player.chat_color = color
|
||||
end)
|
||||
@@ -0,0 +1,139 @@
|
||||
local Game = require 'utils.game'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local Public = {
|
||||
user_reports={},
|
||||
player_report_added = script.generate_event_name(),
|
||||
player_report_removed = script.generate_event_name()
|
||||
}
|
||||
|
||||
Global.register(Public.user_reports,function(tbl)
|
||||
Public.user_reports = tbl
|
||||
end)
|
||||
|
||||
local function event_emit(event,player,by_player_name)
|
||||
local reports = Public.user_reports[player.name]
|
||||
local reason = reports and reports[by_player_name]
|
||||
script.raise_event(event,{
|
||||
name=event,
|
||||
tick=game.tick,
|
||||
player_index=player.index,
|
||||
by_player_name=by_player_name,
|
||||
reason=reason
|
||||
})
|
||||
end
|
||||
|
||||
--- Adds a report to a player, reports are stored in global table and can be accessed later
|
||||
-- @tparam player LuaPlayer the player that will be reported
|
||||
-- @tparam[opt='Non Given.'] reason string the reason that the player is being reported
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player doing the action
|
||||
-- @treturn boolean true if the report was added, nil if there is an error
|
||||
function Public.report_player(player,reason,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
reason = reason or 'Non Given.'
|
||||
by_player_name = by_player_name or '<server>'
|
||||
local reports = Public.user_reports[player.name]
|
||||
if not reports then
|
||||
Public.user_reports[player.name] = {
|
||||
[by_player_name] = reason
|
||||
}
|
||||
elseif not reports[by_player_name] then
|
||||
reports[by_player_name] = reason
|
||||
else return false end
|
||||
event_emit(Public.player_report_added,player,by_player_name)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Removes a report from a player by the given player, see clear_player_reports to remove all
|
||||
-- @tparam player LuaPlayer the player that will have the report removed
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player doing the action
|
||||
-- @treturn boolean true if the report was removed, nil if there was an error
|
||||
function Public.remove_player_report(player,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
by_player_name = by_player_name or '<server>'
|
||||
local reports = Public.user_reports[player.name]
|
||||
if reports and reports[by_player_name] then
|
||||
event_emit(Public.player_report_removed,player,by_player_name)
|
||||
reports[by_player_name] = nil
|
||||
if Public.count_player_reports(player) == 0 then
|
||||
Public.user_reports[player.name] = nil
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Clears all reports from a player, will emit an event for each individual report as if remove_player_report was used
|
||||
-- @tparam player LuaPlayer the player to clear the reports of
|
||||
-- @treturn boolean true if the reports were cleared, nil if error
|
||||
function Public.clear_player_reports(player)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local reports = Public.user_reports[player.name]
|
||||
if reports then
|
||||
for by_player_name,reason in pairs(reports) do
|
||||
event_emit(Public.player_report_removed,player,by_player_name)
|
||||
end
|
||||
Public.user_reports[player.name] = nil
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Test for if a player has been reported by another player, can also return the reason from that player
|
||||
-- @tparam player LuaPlayer the player to check the reports of
|
||||
-- @tparam by_player_name string the player that made if the report if present (note server is not default here)
|
||||
-- @tparam[opt=false] rtn_reason boolean true will return the reason for the report rather than a boolean
|
||||
-- @treturn boolean true if a report from the player is present unless rtn_reason is true when a string is returned (or false)
|
||||
function Public.player_is_reported_by(player,by_player_name,rtn_reason)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local reports = Public.user_reports[player.name]
|
||||
if reports and reports[by_player_name] then
|
||||
return rtn_reason and reports[by_player_name] or true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Gets all the reports that are on a player
|
||||
-- @tparam player LuaPlayer the player to get the reports of
|
||||
-- @treturn table a table of all the reports for this player, empty table if no reports
|
||||
function Public.get_player_reports(player)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
return Public.user_reports[player.name] or {}
|
||||
end
|
||||
|
||||
--- Counts all reports on a player returning a number, a custom count function can be given which should return a number
|
||||
-- @tparam player LuaPlayer the player to count the reports of
|
||||
-- @tparam[opt] count_callback function should return a number or true (for 1) this will be passed every report on the player
|
||||
-- count_callback param - player_name string - the name of the player who made the report
|
||||
-- count_callback param - reason string - the reason the reason was made
|
||||
-- count_callback return - number or boolean - if number then this will be added to the count, if boolean then false = 0 and true = 1
|
||||
-- @treturn number the number of reports on the player
|
||||
function Public.count_player_reports(player,count_callback)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local reports = Public.user_reports[player.name] or {}
|
||||
if not count_callback then
|
||||
local ctn = 0
|
||||
for _ in pairs(reports) do
|
||||
ctn=ctn+1
|
||||
end
|
||||
return ctn
|
||||
else
|
||||
local ctn = 0
|
||||
for player_name,reason in pairs(reports) do
|
||||
local success,err = pcall(count_callback,player_name,reason)
|
||||
if success and err then
|
||||
if err == true then err = 1 end
|
||||
ctn = ctn+err
|
||||
end
|
||||
end
|
||||
return ctn
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
||||
@@ -141,4 +141,7 @@ Event.add(defines.events.on_player_created, function(event)
|
||||
spawn_belts(s,p)
|
||||
spawn_turrets()
|
||||
player.teleport(p,s)
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Way to access global table
|
||||
return turrets
|
||||
@@ -0,0 +1,219 @@
|
||||
local Game = require 'utils.game'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local config = require 'config.warnings'
|
||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||
require 'utils.table'
|
||||
|
||||
local Public = {
|
||||
user_warnings={},
|
||||
user_temp_warnings={},
|
||||
player_warning_added = script.generate_event_name(),
|
||||
player_warning_removed = script.generate_event_name(),
|
||||
player_temp_warning_added = script.generate_event_name(),
|
||||
player_temp_warning_removed = script.generate_event_name()
|
||||
}
|
||||
|
||||
Global.register({
|
||||
Public.user_warnings,
|
||||
Public.user_temp_warnings
|
||||
},function(tbl)
|
||||
Public.user_warnings = tbl[1]
|
||||
Public.user_temp_warnings = tbl[2]
|
||||
end)
|
||||
|
||||
local function event_emit(event,player,by_player_name)
|
||||
local warnings = Public.user_warnings[player.name] or {}
|
||||
local temp_warnings = Public.user_temp_warnings[player.name] or {}
|
||||
script.raise_event(event,{
|
||||
name=event,
|
||||
tick=game.tick,
|
||||
player_index=player.index,
|
||||
by_player_name=by_player_name,
|
||||
warning_count=#warnings,
|
||||
temp_warning_count=#temp_warnings
|
||||
})
|
||||
end
|
||||
|
||||
--- Adds X number (default 1) of warnings to a player from the given player
|
||||
-- @tparam player LuaPlayer the player to add the warning to
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player doing the action
|
||||
-- @tparam[opt=1] count number the number of warnings to add
|
||||
-- @treturn number the new number of warnings
|
||||
function Public.add_warnings(player,by_player_name,count)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
count = count or 1
|
||||
by_player_name = by_player_name or '<server>'
|
||||
local warnings = Public.user_warnings[player.name]
|
||||
if not warnings then
|
||||
Public.user_warnings[player.name] = {}
|
||||
warnings = Public.user_warnings[player.name]
|
||||
end
|
||||
for _=1,count do
|
||||
table.insert(warnings,by_player_name)
|
||||
event_emit(Public.player_warning_added,player,by_player_name)
|
||||
end
|
||||
return #warnings
|
||||
end
|
||||
|
||||
--- Removes X number (default 1) of warnings from a player, removes in order fifo
|
||||
-- @tparam player LuaPlayer the player to remove the warnings from
|
||||
-- @tparam[opt='<server>'] by_playey_name string the name of the player doing the action
|
||||
-- @tparam[opt=1] count number the number of warnings to remove (if greater than current warning count then all are removed)
|
||||
-- @treturn number the new number of warnings
|
||||
function Public.remove_warnings(player,by_player_name,count)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
count = count or 1
|
||||
by_player_name = by_player_name or '<server>'
|
||||
local warnings = Public.user_warnings[player.name]
|
||||
if not warnings then return end
|
||||
for _=1,count do
|
||||
if #warnings == 0 then break end
|
||||
table.remove(warnings,1)
|
||||
event_emit(Public.player_warning_removed,player,by_player_name)
|
||||
end
|
||||
if #warnings == 0 then
|
||||
Public.user_warnings[player.name] = nil
|
||||
return 0
|
||||
end
|
||||
return #warnings
|
||||
end
|
||||
|
||||
--- Clears all warnings from a player, emits event multiple times as if remove_warnings was used
|
||||
-- @tparam player LuaPlayer the player to clear the warnings of
|
||||
-- @tparam[oot='<server>'] by_player_name string the name of the player who is doing the action
|
||||
-- @treturn boolean true if the warnings were cleared, nil if error
|
||||
function Public.clear_warnings(player,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local warnings = Public.user_warnings[player.name]
|
||||
if not warnings then return end
|
||||
by_player_name = by_player_name or '<server>'
|
||||
for _=1,#warnings do
|
||||
event_emit(Public.player_warning_removed,player,by_player_name)
|
||||
end
|
||||
Public.user_warnings[player.name] = {}
|
||||
return true
|
||||
end
|
||||
|
||||
--- Gets the number of warnings that a player has, raw table will contain the names of who gave warnings
|
||||
-- @tparam player LuaPlayer the player to get the warnings of
|
||||
-- @tparam[opt=false] raw_table when true will return a table which contains who gave warnings (the table stored in global)
|
||||
-- @treturn number the number of warnings a player has, a table if raw_table is true
|
||||
function Public.get_warnings(player,raw_table)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local warnings = Public.user_warnings[player.name] or {}
|
||||
if raw_table then
|
||||
return warnings
|
||||
else
|
||||
return #warnings
|
||||
end
|
||||
end
|
||||
|
||||
--- Adds a temp warning to a player that will timeout after some time, used for script given warnings (ie silent to outside players as a buffer)
|
||||
-- @tparam player LuaPlayer the player to give the warnings to
|
||||
-- @tparam[opt=1] count number the number of warnings to give to the player
|
||||
-- @treturn number the new number of warnings
|
||||
function Public.add_temp_warnings(player,count)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
count = count or 1
|
||||
local warnings = Public.user_temp_warnings[player.name]
|
||||
if not warnings then
|
||||
Public.user_temp_warnings[player.name] = {}
|
||||
warnings = Public.user_temp_warnings[player.name]
|
||||
end
|
||||
for _=1,count do
|
||||
table.insert(warnings,game.tick)
|
||||
event_emit(Public.player_temp_warning_added,player,'<server>')
|
||||
end
|
||||
return #warnings
|
||||
end
|
||||
|
||||
-- temp warnings cant be removed on demand only after X amount of time
|
||||
local temp_warning_cool_down = config.temp_warning_cool_down*3600
|
||||
Event.on_nth_tick(temp_warning_cool_down/4,function()
|
||||
local check_time = game.tick-temp_warning_cool_down
|
||||
for player_name,temp_warnings in pairs(Public.user_temp_warnings) do
|
||||
local player = Game.get_player_from_any(player)
|
||||
for index,time in pairs(temp_warnings) do
|
||||
if time <= check_time then
|
||||
table.remove(temp_warnings,index)
|
||||
player.print{'warnings.script-warning-removed',#temp_warnings,config.temp_warning_limit}
|
||||
event_emit(Public.player_temp_warning_removed,player,'<server>')
|
||||
end
|
||||
end
|
||||
if #temp_warnings == 0 then
|
||||
Public.user_temp_warnings[player_name] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--- Clears all temp warnings from a player, emits events as if the warnings had been removed due to time
|
||||
-- @tparam player LuaPlayer the player to clear the warnings of
|
||||
-- @tparam[opt='<server>'] by_player_name string the name of the player doing the action
|
||||
-- @treturn boolean true if the warnings were cleared, nil for error
|
||||
function Public.clear_temp_warnings(player,by_player_name)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local warnings = Public.user_temp_warnings[player.name]
|
||||
if not warnings then return end
|
||||
by_player_name = by_player_name or '<server>'
|
||||
for _=1,#warnings do
|
||||
event_emit(Public.player_temp_warning_removed,player,by_player_name)
|
||||
end
|
||||
Public.user_temp_warnings[player.name] = {}
|
||||
return true
|
||||
end
|
||||
|
||||
--- Gets the number of temp warnings, raw table is a table of when temp warnings were given
|
||||
-- @tparam player LuaPlayer the player to get the warnings of
|
||||
-- @tparam[opt=false] raw_table if true will return a table of ticks when warnings were added (the global table)
|
||||
-- @treturn number the number of warnings which the player has, a table if raw_table is true
|
||||
function Public.get_temp_warnings(player,raw_table)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local warnings = Public.user_temp_warnings[player.name] or {}
|
||||
if raw_table then
|
||||
return warnings
|
||||
else
|
||||
return #warnings
|
||||
end
|
||||
end
|
||||
|
||||
-- when a player gets a warning the actions in config are ran
|
||||
Event.add(Public.player_warning_added,function(event)
|
||||
local action = config.actions[event.warning_count]
|
||||
if not action then return end
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
if type(action) == 'function' then
|
||||
-- player: player who got the warnings,by_player_name: player who gave the last warning,number_of_warnings: the current number of warnings
|
||||
local success,err = pcall(action,player,event.by_player_name,event.warning_count)
|
||||
if not success then error(err) end
|
||||
elseif type(action) == 'table' then
|
||||
-- {locale,by_player_name,number_of_warning,...}
|
||||
local current_action = table.deep_copy(action)
|
||||
table.insert(current_action,2,event.by_player_name)
|
||||
table.insert(current_action,3,event.warning_count)
|
||||
player.print(current_action)
|
||||
elseif type(action) == 'string' then
|
||||
player.print(action)
|
||||
end
|
||||
end)
|
||||
|
||||
-- when a player gets a tempo warnings it is checked that it is not above the max
|
||||
Event.add(Public.player_temp_warning_added,function(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
if event.temp_warning_count > config.temp_warning_limit then
|
||||
Public.add_warnings(event.player_index,event.by_player_name)
|
||||
local player_name_color = format_chat_player_name(player)
|
||||
game.print{'warnings.script-warning-limit',player_name_color}
|
||||
else
|
||||
player.print{'warnings.script-warning',event.temp_warning_count,config.temp_warning_limit}
|
||||
end
|
||||
end)
|
||||
|
||||
return Public
|
||||
@@ -1,4 +1,5 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||
require 'config.command_parse_general'
|
||||
|
||||
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
|
||||
@@ -7,12 +8,10 @@ Commands.new_command('admin-chat','Sends a message in chat that only admins can
|
||||
:set_flag('admin_only',true)
|
||||
:add_alias('ac')
|
||||
:register(function(player,message,raw)
|
||||
local pcc = player and player.chat_color or {r=255,g=255,b=255}
|
||||
local player_name = player and player.name or '<Server>'
|
||||
local colour = string.format('%s,%s,%s',pcc.r,pcc.g,pcc.b)
|
||||
local player_name_colour = format_chat_player_name(player)
|
||||
for _,return_player in pairs(game.connected_players) do
|
||||
if return_player.admin then
|
||||
return_player.print{'exp-commands.admin-chat-format',player_name,message,colour}
|
||||
return_player.print{'exp-commands.admin-chat-format',player_name_colour,message}
|
||||
end
|
||||
end
|
||||
return Commands.success -- prevents command complete message from showing
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local move_items = ext_require('expcore.common','move_items')
|
||||
require 'config.command_parse_roles'
|
||||
|
||||
Commands.new_command('clear-inventory','Clears a players inventory')
|
||||
:add_param('player',false,'player-role-alive')
|
||||
:add_alias('clear-inv','move-inventory','move-inv')
|
||||
:register(function(player,action_player)
|
||||
local inv = action_player.get_main_inventory()
|
||||
move_items(inv.get_contents())
|
||||
inv.clear()
|
||||
end)
|
||||
@@ -72,4 +72,7 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
|
||||
end
|
||||
-- blocks command complete message
|
||||
return Commands.success
|
||||
end)
|
||||
end)
|
||||
|
||||
-- way to access global
|
||||
return search_cache
|
||||
@@ -91,4 +91,8 @@ add_interface_callback('position',function(player) return player.position end)
|
||||
add_interface_callback('entity',function(player) return player.selected end)
|
||||
add_interface_callback('tile',function(player) return player.surface.get_tile(player.position) end)
|
||||
|
||||
return add_interface_callback
|
||||
return {
|
||||
add_interface_callback=add_interface_callback,
|
||||
interface_env=interface_env,
|
||||
interface_callbacks=interface_callbacks
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local JailControl = require 'modules.addons.jail-control'
|
||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||
require 'config.command_parse_roles'
|
||||
|
||||
Commands.new_command('jail','Puts a player into jail and removes all other roles.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('reason',true)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
reason = reason or 'Non Given.'
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if JailControl.jail_player(action_player,player.name) then
|
||||
game.print{'exp-commands.jail-give',action_player_name_color,by_player_name_color,reason}
|
||||
else
|
||||
return Commands.error{'exp-commands.jail-already-jailed',action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('unjail','Puts a player into jail and removes all other roles.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_alias('clear-jail','remove-jail')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,raw)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if JailControl.unjail_player(action_player,player.name) then
|
||||
game.print{'exp-commands.jail-remove',action_player_name_color,by_player_name_color}
|
||||
else
|
||||
return Commands.error{'exp-commands.jail-not-jailed',action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('temp-ban','Temp bans a player until the next reset; this requires a reason; this will clear the players inventory.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('reason',false)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if JailControl.temp_ban_player(action_player,player.name,reason) then
|
||||
game.print{'exp-commands.jail-temp-ban',action_player_name_color,by_player_name_color,reason}
|
||||
else
|
||||
return Commands.error{'exp-commands.jail-already-banned',action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('clear-temp-ban','Removes temp ban from a player; this will not restore they items.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_alias('untemp-ban','remove-temp-ban')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,raw)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if JailControl.clear_temp_ban_player(action_player,player.name) then
|
||||
game.print{'exp-commands.jail-temp-ban-clear',action_player_name_color,by_player_name_color}
|
||||
else
|
||||
return Commands.error{'exp-commands.jail-not-temp-banned',action_player_name_color}
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,44 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local config = require 'config.repair'
|
||||
require 'config.command_parse_general'
|
||||
|
||||
local max_time_to_live = 4294967295 -- unit32 max
|
||||
Commands.new_command('repair','Repairs entities on your force around you')
|
||||
:add_param('range',false,'integer-range',1,config.max_range)
|
||||
:register(function(player,range,raw)
|
||||
local revive_count = 0
|
||||
local heal_count = 0
|
||||
local range2 = range^2
|
||||
local surface = player.surface
|
||||
local center = player.position
|
||||
local area = {{x=center.x-range,y=center.y-range},{x=center.x+range,y=center.y+range}}
|
||||
if config.allow_ghost_revive then
|
||||
local ghosts = surface.find_entities_filtered({area=area,type='entity-ghost',force=player.force})
|
||||
for _,ghost in pairs(ghosts) do
|
||||
if ghost.valid then
|
||||
local x = ghost.position.x-center.x
|
||||
local y = ghost.position.y-center.y
|
||||
if x^2+y^2 <= range2 then
|
||||
if config.allow_blueprint_repair or ghost.time_to_live ~= max_time_to_live then
|
||||
revive_count = revive_count+1
|
||||
if not config.disallow[ghost.ghost_name] then ghost.revive() end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if config.allow_heal_entities then
|
||||
local entities = surface.find_entities_filtered({area=area,force=player.force})
|
||||
for _,entity in pairs(entities) do
|
||||
if entity.valid then
|
||||
local x = entity.position.x-center.x
|
||||
local y = entity.position.y-center.y
|
||||
if entity.health and entity.get_health_ratio() ~= 1 and x^2+y^2 <= range2 then
|
||||
heal_count = heal_count+1
|
||||
entity.health = max_time_to_live
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return Commands.success{'exp-commands.repair-result',revive_count,heal_count}
|
||||
end)
|
||||
@@ -0,0 +1,70 @@
|
||||
local Roles = require 'expcore.roles'
|
||||
local Commands = require 'expcore.commands'
|
||||
local ReportsControl = require 'modules.addons.reports-control'
|
||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||
require 'config.command_parse_general'
|
||||
|
||||
Commands.new_command('report','Reports a player and notifies moderators')
|
||||
:add_param('player',false,function(input,player,reject)
|
||||
input = Commands.parse('player',input,player,reject)
|
||||
if not input then return end
|
||||
if Roles.player_has_flag(input,'report-immune') then
|
||||
return reject{'exp-commands.report-player-immune'}
|
||||
else
|
||||
return input
|
||||
end
|
||||
end)
|
||||
:add_param('reason',false)
|
||||
:add_alias('report-player')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if ReportsControl.report_player(action_player,reason,player.name) then
|
||||
game.print{'exp-commands.report-non-admin',action_player_name_color,reason}
|
||||
Roles.print_to_roles_higher('Trainee',{'exp-commands.report-admin',action_player_name_color,by_player_name_color,reason})
|
||||
else
|
||||
return Commands.error{'exp-commands.report-already-reported'}
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('get-reports','Gets a list of all reports that a player has on them. If no player then lists all players and the number of reports on them.')
|
||||
:add_param('player',true,'player')
|
||||
:add_alias('reports','list-reports')
|
||||
:register(function(player,action_player,raw)
|
||||
if action_player then
|
||||
local reports = ReportsControl.get_player_reports(action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
Commands.print{'exp-commands.report-player-report-title',action_player_name_color}
|
||||
for player_name,reason in pairs(reports) do
|
||||
local by_player_name_color = format_chat_player_name(player_name)
|
||||
Commands.print{'exp-commands.report-list',by_player_name_color,reason}
|
||||
end
|
||||
else
|
||||
local user_reports = ReportsControl.user_reports
|
||||
Commands.print{'exp-commands.report-player-count-title'}
|
||||
for player_name,reports in pairs(user_reports) do
|
||||
local player_name_color = format_chat_player_name(player_name)
|
||||
local report_count = ReportsControl.count_player_reports(player_name)
|
||||
Commands.print{'exp-commands.report-list',player_name_color,report_count}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('clear-reports','Clears all reports from a player or just the report from one player.')
|
||||
:add_param('player',false,'player')
|
||||
:add_param('from-player',true,'player')
|
||||
:register(function(player,action_player,from_player,raw)
|
||||
if from_player then
|
||||
if not ReportsControl.remove_player_report(action_player,from_player.name) then
|
||||
return Commands.error{'exp-commands.report-not-reported'}
|
||||
end
|
||||
else
|
||||
if not ReportsControl.clear_player_reports(action_player) then
|
||||
return Commands.error{'exp-commands.report-not-reported'}
|
||||
end
|
||||
end
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'exp-commands.report-removed',action_player_name_color,by_player_name_color}
|
||||
end)
|
||||
@@ -1,6 +1,10 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local Roles = require 'expcore.roles'
|
||||
local Colours = require 'resources.color_presets'
|
||||
local format_chat_player_name, format_chat_colour_localized = ext_require('expcore.common',
|
||||
'format_chat_player_name',
|
||||
'format_chat_colour_localized'
|
||||
)
|
||||
|
||||
Commands.new_command('assign-role','Assigns a role to a player')
|
||||
:add_param('player',false,'player-role')
|
||||
@@ -36,22 +40,21 @@ Commands.new_command('list-roles','Lists all roles in they correct order')
|
||||
:register(function(player,action_player,raw)
|
||||
local roles = Roles.config.order
|
||||
local message = {'exp-commands.roles-list'}
|
||||
if action_player ~= '' then
|
||||
if action_player then
|
||||
roles = Roles.get_player_roles(action_player)
|
||||
end
|
||||
for index,role in pairs(roles) do
|
||||
role = Roles.get_role_from_any(role)
|
||||
local colour = role.custom_color or Colours.white
|
||||
colour = string.format('%d,%d,%d',colour.r,colour.g,colour.b)
|
||||
local role_name = format_chat_colour_localized(role.name,colour)
|
||||
if index == 1 then
|
||||
message = {'exp-commands.roles-list',colour,role.name}
|
||||
if action_player ~= '' then
|
||||
local player_colour = action_player.color
|
||||
player_colour = string.format('%d,%d,%d',player_colour.r*255,player_colour.g*255,player_colour.b*255)
|
||||
message = {'exp-commands.roles-list-player',player_colour,action_player.name,colour,role.name}
|
||||
message = {'exp-commands.roles-list',role_name}
|
||||
if action_player then
|
||||
local player_name_colour = format_chat_player_name(action_player)
|
||||
message = {'exp-commands.roles-list-player',player_name_colour,role_name}
|
||||
end
|
||||
else
|
||||
message = {'exp-commands.roles-list-element',message,colour,role.name}
|
||||
message = {'exp-commands.roles-list-element',message,role_name}
|
||||
end
|
||||
end
|
||||
return Commands.success(message)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local Roles = require 'expcore.roles'
|
||||
|
||||
local function teleport(player)
|
||||
local surface = player.surface
|
||||
local spawn = player.force.get_spawn_position(surface)
|
||||
local position = surface.find_non_colliding_position('player',spawn,32,1)
|
||||
if not position then return false end
|
||||
if player.driving then player.driving = false end -- kicks a player out a vehicle if in one
|
||||
player.teleport(position,surface)
|
||||
return true
|
||||
end
|
||||
|
||||
Commands.new_command('go-to-spawn','Teleport to spawn')
|
||||
:add_param('player',true,'player-role-alive')
|
||||
:set_defaults{
|
||||
player=function(player)
|
||||
if player.connected and player.character and player.character.health > 0 then
|
||||
return player
|
||||
end
|
||||
end
|
||||
}
|
||||
:add_alias('spawn','tp-spawn')
|
||||
:register(function(player,action_player)
|
||||
if not action_player then
|
||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
||||
elseif action_player == player then
|
||||
if not teleport(player) then
|
||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
||||
end
|
||||
elseif Roles.player_allowed(player,'command/go-to-spawn/always') then
|
||||
if not teleport(action_player) then
|
||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
||||
end
|
||||
else
|
||||
return Commands.error{'expcore-commands.unauthorized'}
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,57 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local WarningsControl = require 'modules.addons.warnings-control'
|
||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||
local config = require 'config.warnings'
|
||||
require 'config.command_parse_roles'
|
||||
|
||||
Commands.new_command('give-warning','Gives a warning to a player; may lead to automatic script action.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('reason',false)
|
||||
:add_alias('warn')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
WarningsControl.add_warnings(action_player,player.name)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'exp-commands.warnings-received',action_player_name_color,by_player_name_color,reason}
|
||||
end)
|
||||
|
||||
Commands.new_command('get-warnings','Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.')
|
||||
:add_param('player',true,'player')
|
||||
:add_alias('warnings','list-warnings')
|
||||
:register(function(player,action_player,raw)
|
||||
if action_player then
|
||||
local warnings = WarningsControl.get_warnings(action_player)
|
||||
local script_warnings = WarningsControl.get_temp_warnings(action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
Commands.print{'exp-commands.warnings-player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
|
||||
else
|
||||
local rtn = {}
|
||||
local user_warnings = WarningsControl.user_warnings
|
||||
local user_temp_warnings = WarningsControl.user_temp_warnings
|
||||
for player_name,warnings in pairs(user_warnings) do
|
||||
rtn[player_name] = {#warnings,0}
|
||||
end
|
||||
for player_name,warnings in pairs(user_temp_warnings) do
|
||||
if not rtn[player_name] then
|
||||
rtn[player_name] = {0,0}
|
||||
end
|
||||
rtn[player_name][2] = #warnings
|
||||
end
|
||||
Commands.print{'exp-commands.warnings-list-tilte'}
|
||||
for player_name,warnings in pairs(rtn) do
|
||||
local player_name_color = format_chat_player_name(player_name)
|
||||
Commands.print{'exp-commands.warnings-list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('clear-warnings','Clears all warnings (and script warnings) from a player')
|
||||
:add_param('player',false,'player')
|
||||
:register(function(player,action_player,raw)
|
||||
WarningsControl.clear_warnings(action_player,player.name)
|
||||
WarningsControl.clear_temp_warnings(action_player,player.name)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'exp-commands.warnings-cleared',action_player_name_color,by_player_name_color}
|
||||
end)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user