From 0123451267495943224dbabe6b12f899cf571cd1 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Tue, 16 Apr 2019 19:31:58 +0100 Subject: [PATCH 01/18] gitflow-feature-stash: jail --- old/modules/{ => DONE}/FactorioStdLib/Color/control.lua | 0 old/modules/{ => DONE}/FactorioStdLib/Color/softmod.json | 0 old/modules/{ => DONE}/FactorioStdLib/Game/control.lua | 0 old/modules/{ => DONE}/FactorioStdLib/Game/softmod.json | 0 old/modules/{ => DONE}/FactorioStdLib/String/control.lua | 0 old/modules/{ => DONE}/FactorioStdLib/String/softmod.json | 0 old/modules/{ => DONE}/FactorioStdLib/Table/control.lua | 0 old/modules/{ => DONE}/FactorioStdLib/Table/softmod.json | 0 old/modules/{ => DONE}/FactorioStdLib/softmod.json | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename old/modules/{ => DONE}/FactorioStdLib/Color/control.lua (100%) rename old/modules/{ => DONE}/FactorioStdLib/Color/softmod.json (100%) rename old/modules/{ => DONE}/FactorioStdLib/Game/control.lua (100%) rename old/modules/{ => DONE}/FactorioStdLib/Game/softmod.json (100%) rename old/modules/{ => DONE}/FactorioStdLib/String/control.lua (100%) rename old/modules/{ => DONE}/FactorioStdLib/String/softmod.json (100%) rename old/modules/{ => DONE}/FactorioStdLib/Table/control.lua (100%) rename old/modules/{ => DONE}/FactorioStdLib/Table/softmod.json (100%) rename old/modules/{ => DONE}/FactorioStdLib/softmod.json (100%) diff --git a/old/modules/FactorioStdLib/Color/control.lua b/old/modules/DONE/FactorioStdLib/Color/control.lua similarity index 100% rename from old/modules/FactorioStdLib/Color/control.lua rename to old/modules/DONE/FactorioStdLib/Color/control.lua diff --git a/old/modules/FactorioStdLib/Color/softmod.json b/old/modules/DONE/FactorioStdLib/Color/softmod.json similarity index 100% rename from old/modules/FactorioStdLib/Color/softmod.json rename to old/modules/DONE/FactorioStdLib/Color/softmod.json diff --git a/old/modules/FactorioStdLib/Game/control.lua b/old/modules/DONE/FactorioStdLib/Game/control.lua similarity index 100% rename from old/modules/FactorioStdLib/Game/control.lua rename to old/modules/DONE/FactorioStdLib/Game/control.lua diff --git a/old/modules/FactorioStdLib/Game/softmod.json b/old/modules/DONE/FactorioStdLib/Game/softmod.json similarity index 100% rename from old/modules/FactorioStdLib/Game/softmod.json rename to old/modules/DONE/FactorioStdLib/Game/softmod.json diff --git a/old/modules/FactorioStdLib/String/control.lua b/old/modules/DONE/FactorioStdLib/String/control.lua similarity index 100% rename from old/modules/FactorioStdLib/String/control.lua rename to old/modules/DONE/FactorioStdLib/String/control.lua diff --git a/old/modules/FactorioStdLib/String/softmod.json b/old/modules/DONE/FactorioStdLib/String/softmod.json similarity index 100% rename from old/modules/FactorioStdLib/String/softmod.json rename to old/modules/DONE/FactorioStdLib/String/softmod.json diff --git a/old/modules/FactorioStdLib/Table/control.lua b/old/modules/DONE/FactorioStdLib/Table/control.lua similarity index 100% rename from old/modules/FactorioStdLib/Table/control.lua rename to old/modules/DONE/FactorioStdLib/Table/control.lua diff --git a/old/modules/FactorioStdLib/Table/softmod.json b/old/modules/DONE/FactorioStdLib/Table/softmod.json similarity index 100% rename from old/modules/FactorioStdLib/Table/softmod.json rename to old/modules/DONE/FactorioStdLib/Table/softmod.json diff --git a/old/modules/FactorioStdLib/softmod.json b/old/modules/DONE/FactorioStdLib/softmod.json similarity index 100% rename from old/modules/FactorioStdLib/softmod.json rename to old/modules/DONE/FactorioStdLib/softmod.json From eb4c389673e9e090a95d493f4aff7b17b6c7f7fd Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Tue, 16 Apr 2019 20:46:42 +0100 Subject: [PATCH 02/18] Added Jail and some other stuff --- config/roles.lua | 11 +++---- expcore/common.lua | 29 +++++++++++++++++ expcore/roles.lua | 58 ++++++++++++++++++++------------- locale/en/commands.cfg | 12 ++++--- locale/en/expcore.cfg | 1 + modules/addons/compilatron.lua | 34 +++++++++---------- modules/addons/death-logger.lua | 4 +-- modules/addons/jail-control.lua | 41 +++++++++++++++++++++++ modules/addons/spawn-area.lua | 5 ++- modules/commands/admin-chat.lua | 7 ++-- modules/commands/help.lua | 5 ++- modules/commands/interface.lua | 6 +++- modules/commands/jail.lua | 32 ++++++++++++++++++ modules/commands/roles.lua | 15 +++++---- 14 files changed, 194 insertions(+), 66 deletions(-) create mode 100644 modules/addons/jail-control.lua create mode 100644 modules/commands/jail.lua diff --git a/config/roles.lua b/config/roles.lua index 2e239c19..b203201d 100644 --- a/config/roles.lua +++ b/config/roles.lua @@ -147,7 +147,7 @@ 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{ @@ -164,15 +164,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 +183,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{ diff --git a/expcore/common.lua b/expcore/common.lua index 4c3478fa..096e0eeb 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -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 '' + local player_chat_colour = player and player.chat_color or Colors.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 \ No newline at end of file diff --git a/expcore/roles.lua b/expcore/roles.lua index 6cf5b71b..97107404 100644 --- a/expcore/roles.lua +++ b/expcore/roles.lua @@ -114,8 +114,8 @@ 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 +170,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 '' + 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 +203,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 +227,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() @@ -293,7 +305,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=] 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 +318,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=] 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 +338,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 diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 393aae20..0e8549d0 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -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,10 @@ 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] \ No newline at end of file +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. \ No newline at end of file diff --git a/locale/en/expcore.cfg b/locale/en/expcore.cfg index 82d68681..e725bd91 100644 --- a/locale/en/expcore.cfg +++ b/locale/en/expcore.cfg @@ -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 diff --git a/modules/addons/compilatron.lua b/modules/addons/compilatron.lua index f184baf5..29fc2bfe 100644 --- a/modules/addons/compilatron.lua +++ b/modules/addons/compilatron.lua @@ -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.global.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.global.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.global.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.global.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.global.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) diff --git a/modules/addons/death-logger.lua b/modules/addons/death-logger.lua index 938e550f..2d8be85c 100644 --- a/modules/addons/death-logger.lua +++ b/modules/addons/death-logger.lua @@ -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 \ No newline at end of file +return deaths \ No newline at end of file diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua new file mode 100644 index 00000000..f404a81d --- /dev/null +++ b/modules/addons/jail-control.lua @@ -0,0 +1,41 @@ +local Roles = require 'expcore.roles' +local Game = require 'utils.game' +local Global = require 'utils.global' + +local Public = { + old_roles = {} +} +Global.register(Public.old_roles,function(tbl) + Public.old_roles=tbl +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=''] 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 = Role.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) + 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=''] 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) + return #old_roles +end + +return Public \ No newline at end of file diff --git a/modules/addons/spawn-area.lua b/modules/addons/spawn-area.lua index 04c341fa..71f4d062 100644 --- a/modules/addons/spawn-area.lua +++ b/modules/addons/spawn-area.lua @@ -141,4 +141,7 @@ Event.add(defines.events.on_player_created, function(event) spawn_belts(s,p) spawn_turrets() player.teleport(p,s) -end) \ No newline at end of file +end) + +-- Way to access global table +return turrets \ No newline at end of file diff --git a/modules/commands/admin-chat.lua b/modules/commands/admin-chat.lua index c3fb6e5f..e9f32b50 100644 --- a/modules/commands/admin-chat.lua +++ b/modules/commands/admin-chat.lua @@ -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 '' - 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 diff --git a/modules/commands/help.lua b/modules/commands/help.lua index c4a78567..419a23ac 100644 --- a/modules/commands/help.lua +++ b/modules/commands/help.lua @@ -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) \ No newline at end of file +end) + +-- way to access global +return search_cache \ No newline at end of file diff --git a/modules/commands/interface.lua b/modules/commands/interface.lua index 5f1b2b42..6e5b89b0 100644 --- a/modules/commands/interface.lua +++ b/modules/commands/interface.lua @@ -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 \ No newline at end of file +return { + add_interface_callback=add_interface_callback, + interface_env=interface_env, + interface_callbacks=interface_callbacks +} \ No newline at end of file diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua new file mode 100644 index 00000000..04ae8a6d --- /dev/null +++ b/modules/commands/jail.lua @@ -0,0 +1,32 @@ +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') +: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) \ No newline at end of file diff --git a/modules/commands/roles.lua b/modules/commands/roles.lua index 9ae0d0b8..e19d521c 100644 --- a/modules/commands/roles.lua +++ b/modules/commands/roles.lua @@ -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') @@ -42,16 +46,15 @@ Commands.new_command('list-roles','Lists all roles in they correct order') 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} + message = {'exp-commands.roles-list',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} + 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) From c5f1f226c9dc1fbdde099ebd55056a91422b8015 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Tue, 16 Apr 2019 21:09:42 +0100 Subject: [PATCH 03/18] Added Temp Ban --- locale/en/commands.cfg | 6 ++++- modules/addons/jail-control.lua | 43 ++++++++++++++++++++++++++++++--- modules/commands/jail.lua | 32 ++++++++++++++++++++++-- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 0e8549d0..c8b9a2d9 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -15,4 +15,8 @@ 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. \ No newline at end of file +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. diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua index f404a81d..b743e1b7 100644 --- a/modules/addons/jail-control.lua +++ b/modules/addons/jail-control.lua @@ -1,12 +1,18 @@ 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 = {} + old_roles = {}, + temp_bans = {} } -Global.register(Public.old_roles,function(tbl) - Public.old_roles=tbl +Global.register({ + Public.old_roles, + Public.temp_bans +},function(tbl) + Public.old_roles=tbl[1] + Public.temp_bans=tbl[2] end) --- Jails a player, this is only the logic there is no output to players @@ -38,4 +44,35 @@ function Public.unjail_player(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=''] 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() + 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=''] 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 + return true +end + return Public \ No newline at end of file diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua index 04ae8a6d..3c2b74ee 100644 --- a/modules/commands/jail.lua +++ b/modules/commands/jail.lua @@ -3,7 +3,7 @@ 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') +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() @@ -18,7 +18,7 @@ Commands.new_command('jail','Puts a player into jail and removes all other roles end end) -Commands.new_command('unjail','Puts a player into jail and removes all other roles') +Commands.new_command('unjail','Puts a player into jail and removes all other roles.') :add_param('player',false,'player-role') :enable_auto_concat() :register(function(player,action_player,raw) @@ -29,4 +29,32 @@ Commands.new_command('unjail','Puts a player into jail and removes all other rol 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('remove-temp-ban','Removes temp ban from a player; this will not restore they items.') +: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.clear_temp_ban_player(action_player,player.name,reason) 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) \ No newline at end of file From 2c108e679252d1cd336e575394bfcbadbbf06c0e Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 14:34:21 +0100 Subject: [PATCH 04/18] Added report-control --- modules/addons/jail-control.lua | 20 ++++- modules/addons/reports-control.lua | 132 +++++++++++++++++++++++++++++ modules/commands/jail.lua | 2 +- 3 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 modules/addons/reports-control.lua diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua index b743e1b7..a65d6c2e 100644 --- a/modules/addons/jail-control.lua +++ b/modules/addons/jail-control.lua @@ -5,7 +5,11 @@ local move_items = ext_require('expcore.common','move_items') local Public = { old_roles = {}, - temp_bans = {} + 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, @@ -15,6 +19,16 @@ Global.register({ 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=''] by_player_name string the name of the player doing the action used in logs @@ -27,6 +41,7 @@ function Public.jail_player(player,by_player_name) 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 @@ -41,6 +56,7 @@ function Public.unjail_player(player,by_player_name) 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 @@ -59,6 +75,7 @@ function Public.temp_ban_player(player,by_player_name,reason) 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 @@ -72,6 +89,7 @@ function Public.clear_temp_ban_player(player,by_player_name) 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 diff --git a/modules/addons/reports-control.lua b/modules/addons/reports-control.lua new file mode 100644 index 00000000..eacb212b --- /dev/null +++ b/modules/addons/reports-control.lua @@ -0,0 +1,132 @@ +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=''] 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 '' + 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=''] 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 '' + 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 + 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 + return #reports + 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 \ No newline at end of file diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua index 3c2b74ee..adfcd927 100644 --- a/modules/commands/jail.lua +++ b/modules/commands/jail.lua @@ -45,7 +45,7 @@ Commands.new_command('temp-ban','Temp bans a player until the next reset; this r end end) -Commands.new_command('remove-temp-ban','Removes temp ban from a player; this will not restore they items.') +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_param('reason',false) :enable_auto_concat() From 17e61e710b091953c2e755c25dd6ec38a4a85a48 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 15:16:12 +0100 Subject: [PATCH 05/18] Added report commands --- expcore/roles.lua | 44 +++++++++++++++++++++++ locale/en/commands.cfg | 9 +++++ modules/commands/jail.lua | 2 ++ modules/commands/reports.lua | 69 ++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 modules/commands/reports.lua diff --git a/expcore/roles.lua b/expcore/roles.lua index 97107404..f503798d 100644 --- a/expcore/roles.lua +++ b/expcore/roles.lua @@ -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 diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index c8b9a2d9..8bf0ea4b 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -20,3 +20,12 @@ 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__. \ No newline at end of file diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua index adfcd927..d6452252 100644 --- a/modules/commands/jail.lua +++ b/modules/commands/jail.lua @@ -20,6 +20,7 @@ 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) @@ -48,6 +49,7 @@ 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_param('reason',false) +:add_alias('untemp-ban','remove-temp-ban') :enable_auto_concat() :register(function(player,action_player,reason,raw) local action_player_name_color = format_chat_player_name(action_player) diff --git a/modules/commands/reports.lua b/modules/commands/reports.lua new file mode 100644 index 00000000..f1c5c670 --- /dev/null +++ b/modules/commands/reports.lua @@ -0,0 +1,69 @@ +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(player,'report-immune') then + return reject{'exp-command.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) + Commands.print{'exp-commands.report-list',player_name_color,#reports} + 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) 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) \ No newline at end of file From 837da3a4971dfd235e273c066947cc6cdce95454 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 15:37:00 +0100 Subject: [PATCH 06/18] Added warning config --- config/warnings.lua | 19 +++++++++++++++++++ locale/en/addons.cfg | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 config/warnings.lua diff --git a/config/warnings.lua b/config/warnings.lua new file mode 100644 index 00000000..6d05b10c --- /dev/null +++ b/config/warnings.lua @@ -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.recived'}, + {'warnings.recived'}, + {'warnings.recived',{'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.recived',{'warnings.pre-pre-ban'}}, + {'warnings.recived',{'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 + temp_warning_limit=5 -- the number of temp warnings (given by script) that are allowed before full warnings are given +} \ No newline at end of file diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg index d2d99105..9acb6b06 100644 --- a/locale/en/addons.cfg +++ b/locale/en/addons.cfg @@ -25,4 +25,12 @@ 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. \ No newline at end of file +lhd=All trains must be LHD! This is a long standing rule on our servers, please resepect this. + +[warnings] +recived=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. \ No newline at end of file From a8bbe8bcb8a6a4c8d3f02f461ec861c76d5a5d92 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 16:06:55 +0100 Subject: [PATCH 07/18] Added Warning Control --- config/warnings.lua | 2 +- modules/addons/warnings-control.lua | 157 ++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 modules/addons/warnings-control.lua diff --git a/config/warnings.lua b/config/warnings.lua index 6d05b10c..92498102 100644 --- a/config/warnings.lua +++ b/config/warnings.lua @@ -14,6 +14,6 @@ return { 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 + 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 } \ No newline at end of file diff --git a/modules/addons/warnings-control.lua b/modules/addons/warnings-control.lua new file mode 100644 index 00000000..2e689642 --- /dev/null +++ b/modules/addons/warnings-control.lua @@ -0,0 +1,157 @@ +local Game = require 'utils.game' +local Global = require 'utils.global' +local Event = require 'utils.event' +local config = require 'config.warnings' + +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 + +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 '' + 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 + +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 '' + 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 + +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 + for _=1,#warnings do + event_emit(Public.player_warning_removed,player,by_player_name) + end + Public.user_warnings[player.name] = {} + return true +end + +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 + +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,'') + end + return #warnings +end + +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) + event_emit(Public.player_temp_warning_removed,player,'') + end + end + if #temp_warnings == 0 then + Public.user_temp_warnings[player_name] = nil + end + end +end) + +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 + 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 + +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 + +Event.add(Public.player_temp_warning_added,function(event) + if event.temp_warning_count > config.temp_warning_limit then + Public.add_warnings(event.player_index,event.by_player_name) + end +end) + +return Public \ No newline at end of file From 50ff4eae863c3e6d3e7d69a4a965f404d017bb9d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 16:42:06 +0100 Subject: [PATCH 08/18] Added comments --- locale/en/addons.cfg | 4 +- modules/addons/warnings-control.lua | 69 +++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg index 9acb6b06..be0775a6 100644 --- a/locale/en/addons.cfg +++ b/locale/en/addons.cfg @@ -33,4 +33,6 @@ 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. \ No newline at end of file +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__) \ No newline at end of file diff --git a/modules/addons/warnings-control.lua b/modules/addons/warnings-control.lua index 2e689642..235b5b07 100644 --- a/modules/addons/warnings-control.lua +++ b/modules/addons/warnings-control.lua @@ -2,6 +2,7 @@ local Game = require 'utils.game' local Global = require 'utils.global' local Event = require 'utils.event' local config = require 'config.warnings' +require 'utils.table' local Public = { user_warnings={}, @@ -33,6 +34,11 @@ local function event_emit(event,player,by_player_name) }) 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=''] 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 @@ -50,6 +56,11 @@ function Public.add_warnings(player,by_player_name,count) 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=''] 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 @@ -69,11 +80,16 @@ function Public.remove_warnings(player,by_player_name,count) 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=''] 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 '' for _=1,#warnings do event_emit(Public.player_warning_removed,player,by_player_name) end @@ -81,6 +97,10 @@ function Public.clear_warnings(player,by_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 @@ -92,6 +112,10 @@ function Public.get_warnings(player,raw_table) 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 @@ -108,6 +132,7 @@ function Public.add_temp_warnings(player,count) 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 @@ -125,11 +150,16 @@ Event.on_nth_tick(temp_warning_cool_down/4,function() 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=''] 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 '' for _=1,#warnings do event_emit(Public.player_temp_warning_removed,player,by_player_name) end @@ -137,6 +167,10 @@ function Public.clear_temp_warnings(player,by_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 @@ -148,10 +182,39 @@ function Public.get_temp_warnings(player,raw_table) end end -Event.add(Public.player_temp_warning_added,function(event) - if event.temp_warning_count > config.temp_warning_limit then - Public.add_warnings(event.player_index,event.by_player_name) +-- 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,1,event.by_player_name) + table.insert(current_action,1,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) + else + player.print{'warnings.script-warning',event.temp_warning_count,config.temp_warning_limit} + end +end) + +Event.add(Public.player_temp_warning_removed,function(event) + local player = Game.get_player_by_index(event.player_index) + player.print{'warnings.script-warning-removed',event.temp_warning_count,config.temp_warning_limit} +end) + return Public \ No newline at end of file From 6e499e8ce938ca0bf5788e5de622437430c7ae34 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 17:09:25 +0100 Subject: [PATCH 09/18] Added warning commands --- config/warnings.lua | 10 ++--- locale/en/addons.cfg | 2 +- locale/en/commands.cfg | 7 +++- modules/addons/warnings-control.lua | 6 +-- modules/commands/warnings.lua | 57 +++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 modules/commands/warnings.lua diff --git a/config/warnings.lua b/config/warnings.lua index 92498102..5beace17 100644 --- a/config/warnings.lua +++ b/config/warnings.lua @@ -2,14 +2,14 @@ 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.recived'}, - {'warnings.recived'}, - {'warnings.recived',{'warnings.pre-kick'}}, + {'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.recived',{'warnings.pre-pre-ban'}}, - {'warnings.recived',{'warnings.pre-ban'}}, + {'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 diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg index be0775a6..07441927 100644 --- a/locale/en/addons.cfg +++ b/locale/en/addons.cfg @@ -28,7 +28,7 @@ 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. [warnings] -recived=You recived a warning from __1__. You have __2__ warnings. __3__ +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. diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 8bf0ea4b..182899f8 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -28,4 +28,9 @@ 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__. \ No newline at end of file +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__. \ No newline at end of file diff --git a/modules/addons/warnings-control.lua b/modules/addons/warnings-control.lua index 235b5b07..18e12d19 100644 --- a/modules/addons/warnings-control.lua +++ b/modules/addons/warnings-control.lua @@ -141,6 +141,7 @@ Event.on_nth_tick(temp_warning_cool_down/4,function() 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,'') end end @@ -212,9 +213,4 @@ Event.add(Public.player_temp_warning_added,function(event) end end) -Event.add(Public.player_temp_warning_removed,function(event) - local player = Game.get_player_by_index(event.player_index) - player.print{'warnings.script-warning-removed',event.temp_warning_count,config.temp_warning_limit} -end) - return Public \ No newline at end of file diff --git a/modules/commands/warnings.lua b/modules/commands/warnings.lua new file mode 100644 index 00000000..c4fe12f1 --- /dev/null +++ b/modules/commands/warnings.lua @@ -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-warnigns','Clears all warnings (and script warnings) from a player') +:add_param('player',false,'player') +:register(function(player,action_player,raw) + WarningsControl.clear_warnings(player,player.name) + WarningsControl.clear_temp_warnings(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) \ No newline at end of file From 89d52fc73b572d0888c84cd9d02e952461381529 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 22:24:10 +0100 Subject: [PATCH 10/18] Moved Files Around --- .gitignore | 2 + .vscode/settings.json | 31 ---------------- Boiler Print Module | 37 ------------------- README.md | 5 +++ config.ld | 3 -- .../Bot}/autoMessage/control.lua | 0 .../Bot}/autoMessage/locale/de.cfg | 0 .../Bot}/autoMessage/locale/en.cfg | 0 .../Bot}/autoMessage/locale/fr.cfg | 0 .../Bot}/autoMessage/locale/nl.cfg | 0 .../Bot}/autoMessage/locale/sv-SE.cfg | 0 .../Bot}/autoMessage/softmod.json | 0 .../Commands}/cheatMode/control.lua | 0 .../Commands}/cheatMode/softmod.json | 0 .../Commands}/kill/control.lua | 0 .../Commands}/kill/softmod.json | 0 .../Commands}/tags/control.lua | 0 .../Commands}/tags/softmod.json | 0 .../Commands}/teleport/control.lua | 0 .../Commands}/teleport/softmod.json | 0 .../Core}/Command/control.lua | 0 .../Core}/Command/softmod.json | 0 .../Core}/Group/config.lua | 0 .../Core}/Group/control.lua | 0 .../Core}/Group/softmod.json | 0 .../Core}/Role/config.lua | 0 .../Core}/Role/control.lua | 0 .../Core}/Role/locale/en.cfg | 0 .../Core}/Role/softmod.json | 0 .../Core}/Role/src/commands.lua | 0 .../Core}/Role/src/sync.lua | 0 .../ExpAdmin}/Ban/control.lua | 0 .../ExpAdmin}/Ban/softmod.json | 0 .../ExpAdmin}/Commands/control.lua | 0 .../ExpAdmin}/Commands/softmod.json | 0 .../ExpAdmin}/Commands/src/clear.lua | 0 .../ExpAdmin}/Commands/src/jail.lua | 0 .../ExpAdmin}/Commands/src/reports.lua | 0 .../ExpAdmin}/Commands/src/tempban.lua | 0 .../ExpAdmin}/Commands/src/warnings.lua | 0 .../ExpAdmin}/Jail/control.lua | 0 .../ExpAdmin}/Jail/softmod.json | 0 .../ExpAdmin}/Kick/control.lua | 0 .../ExpAdmin}/Kick/softmod.json | 0 .../ExpAdmin}/Reports/control.lua | 0 .../ExpAdmin}/Reports/softmod.json | 0 .../ExpAdmin}/Teleport/control.lua | 0 .../ExpAdmin}/Teleport/softmod.json | 0 .../ExpAdmin}/TempBan/control.lua | 0 .../ExpAdmin}/TempBan/softmod.json | 0 .../ExpAdmin}/Warnings/control.lua | 0 .../ExpAdmin}/Warnings/locale/de.cfg | 0 .../ExpAdmin}/Warnings/locale/en.cfg | 0 .../ExpAdmin}/Warnings/locale/fr.cfg | 0 .../ExpAdmin}/Warnings/locale/nl.cfg | 0 .../ExpAdmin}/Warnings/locale/sv-SE.cfg | 0 .../ExpAdmin}/Warnings/softmod.json | 0 57 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 Boiler Print Module delete mode 100644 config.ld rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/control.lua (100%) rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/locale/de.cfg (100%) rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/locale/en.cfg (100%) rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/locale/fr.cfg (100%) rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/locale/nl.cfg (100%) rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/locale/sv-SE.cfg (100%) rename old/modules/{ExpGamingBot => DONE/Bot}/autoMessage/softmod.json (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/cheatMode/control.lua (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/cheatMode/softmod.json (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/kill/control.lua (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/kill/softmod.json (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/tags/control.lua (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/tags/softmod.json (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/teleport/control.lua (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/teleport/softmod.json (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Command/control.lua (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Command/softmod.json (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Group/config.lua (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Group/control.lua (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Group/softmod.json (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Role/config.lua (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Role/control.lua (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Role/locale/en.cfg (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Role/softmod.json (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Role/src/commands.lua (100%) rename old/modules/{ExpGamingCore => DONE/Core}/Role/src/sync.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Ban/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Ban/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/src/clear.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/src/jail.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/src/reports.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/src/tempban.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Commands/src/warnings.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Jail/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Jail/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Kick/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Kick/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Reports/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Reports/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Teleport/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Teleport/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/TempBan/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/TempBan/softmod.json (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/locale/de.cfg (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/locale/en.cfg (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/locale/fr.cfg (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/locale/nl.cfg (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/locale/sv-SE.cfg (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/Warnings/softmod.json (100%) diff --git a/.gitignore b/.gitignore index 290c8014..4cf9699f 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,5 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +#*.vscode \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 2e87afff..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -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" - ] -} \ No newline at end of file diff --git a/Boiler Print Module b/Boiler Print Module deleted file mode 100644 index b53932ae..00000000 --- a/Boiler Print Module +++ /dev/null @@ -1,37 +0,0 @@ ---- Desction --- @module ThisModule@X.Y.Z --- @author --- @license --- @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 \ No newline at end of file diff --git a/README.md b/README.md index 06976858..ecec858d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,10 @@

ExpGaming Scenario Repository

+

Out Dated; Will be updated in the future

+ #### 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 \ No newline at end of file diff --git a/config.ld b/config.ld deleted file mode 100644 index c79db209..00000000 --- a/config.ld +++ /dev/null @@ -1,3 +0,0 @@ -new_type('command','Commands',false,'param') -new_type('event','Events',false,'field') -new_type('gui','Guis') \ No newline at end of file diff --git a/old/modules/ExpGamingBot/autoMessage/control.lua b/old/modules/DONE/Bot/autoMessage/control.lua similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/control.lua rename to old/modules/DONE/Bot/autoMessage/control.lua diff --git a/old/modules/ExpGamingBot/autoMessage/locale/de.cfg b/old/modules/DONE/Bot/autoMessage/locale/de.cfg similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/locale/de.cfg rename to old/modules/DONE/Bot/autoMessage/locale/de.cfg diff --git a/old/modules/ExpGamingBot/autoMessage/locale/en.cfg b/old/modules/DONE/Bot/autoMessage/locale/en.cfg similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/locale/en.cfg rename to old/modules/DONE/Bot/autoMessage/locale/en.cfg diff --git a/old/modules/ExpGamingBot/autoMessage/locale/fr.cfg b/old/modules/DONE/Bot/autoMessage/locale/fr.cfg similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/locale/fr.cfg rename to old/modules/DONE/Bot/autoMessage/locale/fr.cfg diff --git a/old/modules/ExpGamingBot/autoMessage/locale/nl.cfg b/old/modules/DONE/Bot/autoMessage/locale/nl.cfg similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/locale/nl.cfg rename to old/modules/DONE/Bot/autoMessage/locale/nl.cfg diff --git a/old/modules/ExpGamingBot/autoMessage/locale/sv-SE.cfg b/old/modules/DONE/Bot/autoMessage/locale/sv-SE.cfg similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/locale/sv-SE.cfg rename to old/modules/DONE/Bot/autoMessage/locale/sv-SE.cfg diff --git a/old/modules/ExpGamingBot/autoMessage/softmod.json b/old/modules/DONE/Bot/autoMessage/softmod.json similarity index 100% rename from old/modules/ExpGamingBot/autoMessage/softmod.json rename to old/modules/DONE/Bot/autoMessage/softmod.json diff --git a/old/modules/ExpGamingCommands/cheatMode/control.lua b/old/modules/DONE/Commands/cheatMode/control.lua similarity index 100% rename from old/modules/ExpGamingCommands/cheatMode/control.lua rename to old/modules/DONE/Commands/cheatMode/control.lua diff --git a/old/modules/ExpGamingCommands/cheatMode/softmod.json b/old/modules/DONE/Commands/cheatMode/softmod.json similarity index 100% rename from old/modules/ExpGamingCommands/cheatMode/softmod.json rename to old/modules/DONE/Commands/cheatMode/softmod.json diff --git a/old/modules/ExpGamingCommands/kill/control.lua b/old/modules/DONE/Commands/kill/control.lua similarity index 100% rename from old/modules/ExpGamingCommands/kill/control.lua rename to old/modules/DONE/Commands/kill/control.lua diff --git a/old/modules/ExpGamingCommands/kill/softmod.json b/old/modules/DONE/Commands/kill/softmod.json similarity index 100% rename from old/modules/ExpGamingCommands/kill/softmod.json rename to old/modules/DONE/Commands/kill/softmod.json diff --git a/old/modules/ExpGamingCommands/tags/control.lua b/old/modules/DONE/Commands/tags/control.lua similarity index 100% rename from old/modules/ExpGamingCommands/tags/control.lua rename to old/modules/DONE/Commands/tags/control.lua diff --git a/old/modules/ExpGamingCommands/tags/softmod.json b/old/modules/DONE/Commands/tags/softmod.json similarity index 100% rename from old/modules/ExpGamingCommands/tags/softmod.json rename to old/modules/DONE/Commands/tags/softmod.json diff --git a/old/modules/ExpGamingCommands/teleport/control.lua b/old/modules/DONE/Commands/teleport/control.lua similarity index 100% rename from old/modules/ExpGamingCommands/teleport/control.lua rename to old/modules/DONE/Commands/teleport/control.lua diff --git a/old/modules/ExpGamingCommands/teleport/softmod.json b/old/modules/DONE/Commands/teleport/softmod.json similarity index 100% rename from old/modules/ExpGamingCommands/teleport/softmod.json rename to old/modules/DONE/Commands/teleport/softmod.json diff --git a/old/modules/ExpGamingCore/Command/control.lua b/old/modules/DONE/Core/Command/control.lua similarity index 100% rename from old/modules/ExpGamingCore/Command/control.lua rename to old/modules/DONE/Core/Command/control.lua diff --git a/old/modules/ExpGamingCore/Command/softmod.json b/old/modules/DONE/Core/Command/softmod.json similarity index 100% rename from old/modules/ExpGamingCore/Command/softmod.json rename to old/modules/DONE/Core/Command/softmod.json diff --git a/old/modules/ExpGamingCore/Group/config.lua b/old/modules/DONE/Core/Group/config.lua similarity index 100% rename from old/modules/ExpGamingCore/Group/config.lua rename to old/modules/DONE/Core/Group/config.lua diff --git a/old/modules/ExpGamingCore/Group/control.lua b/old/modules/DONE/Core/Group/control.lua similarity index 100% rename from old/modules/ExpGamingCore/Group/control.lua rename to old/modules/DONE/Core/Group/control.lua diff --git a/old/modules/ExpGamingCore/Group/softmod.json b/old/modules/DONE/Core/Group/softmod.json similarity index 100% rename from old/modules/ExpGamingCore/Group/softmod.json rename to old/modules/DONE/Core/Group/softmod.json diff --git a/old/modules/ExpGamingCore/Role/config.lua b/old/modules/DONE/Core/Role/config.lua similarity index 100% rename from old/modules/ExpGamingCore/Role/config.lua rename to old/modules/DONE/Core/Role/config.lua diff --git a/old/modules/ExpGamingCore/Role/control.lua b/old/modules/DONE/Core/Role/control.lua similarity index 100% rename from old/modules/ExpGamingCore/Role/control.lua rename to old/modules/DONE/Core/Role/control.lua diff --git a/old/modules/ExpGamingCore/Role/locale/en.cfg b/old/modules/DONE/Core/Role/locale/en.cfg similarity index 100% rename from old/modules/ExpGamingCore/Role/locale/en.cfg rename to old/modules/DONE/Core/Role/locale/en.cfg diff --git a/old/modules/ExpGamingCore/Role/softmod.json b/old/modules/DONE/Core/Role/softmod.json similarity index 100% rename from old/modules/ExpGamingCore/Role/softmod.json rename to old/modules/DONE/Core/Role/softmod.json diff --git a/old/modules/ExpGamingCore/Role/src/commands.lua b/old/modules/DONE/Core/Role/src/commands.lua similarity index 100% rename from old/modules/ExpGamingCore/Role/src/commands.lua rename to old/modules/DONE/Core/Role/src/commands.lua diff --git a/old/modules/ExpGamingCore/Role/src/sync.lua b/old/modules/DONE/Core/Role/src/sync.lua similarity index 100% rename from old/modules/ExpGamingCore/Role/src/sync.lua rename to old/modules/DONE/Core/Role/src/sync.lua diff --git a/old/modules/ExpGamingAdmin/Ban/control.lua b/old/modules/DONE/ExpAdmin/Ban/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Ban/control.lua rename to old/modules/DONE/ExpAdmin/Ban/control.lua diff --git a/old/modules/ExpGamingAdmin/Ban/softmod.json b/old/modules/DONE/ExpAdmin/Ban/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Ban/softmod.json rename to old/modules/DONE/ExpAdmin/Ban/softmod.json diff --git a/old/modules/ExpGamingAdmin/Commands/control.lua b/old/modules/DONE/ExpAdmin/Commands/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/control.lua rename to old/modules/DONE/ExpAdmin/Commands/control.lua diff --git a/old/modules/ExpGamingAdmin/Commands/softmod.json b/old/modules/DONE/ExpAdmin/Commands/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/softmod.json rename to old/modules/DONE/ExpAdmin/Commands/softmod.json diff --git a/old/modules/ExpGamingAdmin/Commands/src/clear.lua b/old/modules/DONE/ExpAdmin/Commands/src/clear.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/src/clear.lua rename to old/modules/DONE/ExpAdmin/Commands/src/clear.lua diff --git a/old/modules/ExpGamingAdmin/Commands/src/jail.lua b/old/modules/DONE/ExpAdmin/Commands/src/jail.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/src/jail.lua rename to old/modules/DONE/ExpAdmin/Commands/src/jail.lua diff --git a/old/modules/ExpGamingAdmin/Commands/src/reports.lua b/old/modules/DONE/ExpAdmin/Commands/src/reports.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/src/reports.lua rename to old/modules/DONE/ExpAdmin/Commands/src/reports.lua diff --git a/old/modules/ExpGamingAdmin/Commands/src/tempban.lua b/old/modules/DONE/ExpAdmin/Commands/src/tempban.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/src/tempban.lua rename to old/modules/DONE/ExpAdmin/Commands/src/tempban.lua diff --git a/old/modules/ExpGamingAdmin/Commands/src/warnings.lua b/old/modules/DONE/ExpAdmin/Commands/src/warnings.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Commands/src/warnings.lua rename to old/modules/DONE/ExpAdmin/Commands/src/warnings.lua diff --git a/old/modules/ExpGamingAdmin/Jail/control.lua b/old/modules/DONE/ExpAdmin/Jail/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Jail/control.lua rename to old/modules/DONE/ExpAdmin/Jail/control.lua diff --git a/old/modules/ExpGamingAdmin/Jail/softmod.json b/old/modules/DONE/ExpAdmin/Jail/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Jail/softmod.json rename to old/modules/DONE/ExpAdmin/Jail/softmod.json diff --git a/old/modules/ExpGamingAdmin/Kick/control.lua b/old/modules/DONE/ExpAdmin/Kick/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Kick/control.lua rename to old/modules/DONE/ExpAdmin/Kick/control.lua diff --git a/old/modules/ExpGamingAdmin/Kick/softmod.json b/old/modules/DONE/ExpAdmin/Kick/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Kick/softmod.json rename to old/modules/DONE/ExpAdmin/Kick/softmod.json diff --git a/old/modules/ExpGamingAdmin/Reports/control.lua b/old/modules/DONE/ExpAdmin/Reports/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Reports/control.lua rename to old/modules/DONE/ExpAdmin/Reports/control.lua diff --git a/old/modules/ExpGamingAdmin/Reports/softmod.json b/old/modules/DONE/ExpAdmin/Reports/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Reports/softmod.json rename to old/modules/DONE/ExpAdmin/Reports/softmod.json diff --git a/old/modules/ExpGamingAdmin/Teleport/control.lua b/old/modules/DONE/ExpAdmin/Teleport/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Teleport/control.lua rename to old/modules/DONE/ExpAdmin/Teleport/control.lua diff --git a/old/modules/ExpGamingAdmin/Teleport/softmod.json b/old/modules/DONE/ExpAdmin/Teleport/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Teleport/softmod.json rename to old/modules/DONE/ExpAdmin/Teleport/softmod.json diff --git a/old/modules/ExpGamingAdmin/TempBan/control.lua b/old/modules/DONE/ExpAdmin/TempBan/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/TempBan/control.lua rename to old/modules/DONE/ExpAdmin/TempBan/control.lua diff --git a/old/modules/ExpGamingAdmin/TempBan/softmod.json b/old/modules/DONE/ExpAdmin/TempBan/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/TempBan/softmod.json rename to old/modules/DONE/ExpAdmin/TempBan/softmod.json diff --git a/old/modules/ExpGamingAdmin/Warnings/control.lua b/old/modules/DONE/ExpAdmin/Warnings/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/control.lua rename to old/modules/DONE/ExpAdmin/Warnings/control.lua diff --git a/old/modules/ExpGamingAdmin/Warnings/locale/de.cfg b/old/modules/DONE/ExpAdmin/Warnings/locale/de.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/locale/de.cfg rename to old/modules/DONE/ExpAdmin/Warnings/locale/de.cfg diff --git a/old/modules/ExpGamingAdmin/Warnings/locale/en.cfg b/old/modules/DONE/ExpAdmin/Warnings/locale/en.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/locale/en.cfg rename to old/modules/DONE/ExpAdmin/Warnings/locale/en.cfg diff --git a/old/modules/ExpGamingAdmin/Warnings/locale/fr.cfg b/old/modules/DONE/ExpAdmin/Warnings/locale/fr.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/locale/fr.cfg rename to old/modules/DONE/ExpAdmin/Warnings/locale/fr.cfg diff --git a/old/modules/ExpGamingAdmin/Warnings/locale/nl.cfg b/old/modules/DONE/ExpAdmin/Warnings/locale/nl.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/locale/nl.cfg rename to old/modules/DONE/ExpAdmin/Warnings/locale/nl.cfg diff --git a/old/modules/ExpGamingAdmin/Warnings/locale/sv-SE.cfg b/old/modules/DONE/ExpAdmin/Warnings/locale/sv-SE.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/locale/sv-SE.cfg rename to old/modules/DONE/ExpAdmin/Warnings/locale/sv-SE.cfg diff --git a/old/modules/ExpGamingAdmin/Warnings/softmod.json b/old/modules/DONE/ExpAdmin/Warnings/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Warnings/softmod.json rename to old/modules/DONE/ExpAdmin/Warnings/softmod.json From 2e017dbb706ab1e1efd30c7cbc24caf516d275ed Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 22:44:17 +0100 Subject: [PATCH 11/18] Added go-to-spawn and clear-inventory --- .gitignore | 2 +- locale/en/commands.cfg | 3 +- modules/addons/jail-control.lua | 1 + modules/commands/clear-inventory.lua | 12 ++++++ modules/commands/spawn.lua | 38 +++++++++++++++++++ .../ExpAdmin}/ClearInventory/control.lua | 0 .../ExpAdmin}/ClearInventory/softmod.json | 0 7 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 modules/commands/clear-inventory.lua create mode 100644 modules/commands/spawn.lua rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/ClearInventory/control.lua (100%) rename old/modules/{ExpGamingAdmin => DONE/ExpAdmin}/ClearInventory/softmod.json (100%) diff --git a/.gitignore b/.gitignore index 4cf9699f..697e15f8 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -#*.vscode \ No newline at end of file +*.vscode \ No newline at end of file diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 182899f8..b35ff51f 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -33,4 +33,5 @@ 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__. \ No newline at end of file +warnings-cleared=__1__ had all they warnings cleared by __2__. +spawn-unavailable=They was a problem getting you to spawn, please try again later. \ No newline at end of file diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua index a65d6c2e..7e4aa526 100644 --- a/modules/addons/jail-control.lua +++ b/modules/addons/jail-control.lua @@ -11,6 +11,7 @@ local Public = { player_temp_banned=script.generate_event_name(), player_clear_temp_ban=script.generate_event_name() } + Global.register({ Public.old_roles, Public.temp_bans diff --git a/modules/commands/clear-inventory.lua b/modules/commands/clear-inventory.lua new file mode 100644 index 00000000..28fd9d35 --- /dev/null +++ b/modules/commands/clear-inventory.lua @@ -0,0 +1,12 @@ +local Commands = '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) \ No newline at end of file diff --git a/modules/commands/spawn.lua b/modules/commands/spawn.lua new file mode 100644 index 00000000..0b923222 --- /dev/null +++ b/modules/commands/spawn.lua @@ -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') +:add_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) \ No newline at end of file diff --git a/old/modules/ExpGamingAdmin/ClearInventory/control.lua b/old/modules/DONE/ExpAdmin/ClearInventory/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/ClearInventory/control.lua rename to old/modules/DONE/ExpAdmin/ClearInventory/control.lua diff --git a/old/modules/ExpGamingAdmin/ClearInventory/softmod.json b/old/modules/DONE/ExpAdmin/ClearInventory/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/ClearInventory/softmod.json rename to old/modules/DONE/ExpAdmin/ClearInventory/softmod.json From 652fb42ec9782eb4c40e9ca9966d3df83f5caead Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 23:05:25 +0100 Subject: [PATCH 12/18] Added repair --- config/repair.lua | 13 +++++++++++++ modules/commands/repair.lua | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 config/repair.lua create mode 100644 modules/commands/repair.lua diff --git a/config/repair.lua b/config/repair.lua new file mode 100644 index 00000000..dd58d8be --- /dev/null +++ b/config/repair.lua @@ -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 +} \ No newline at end of file diff --git a/modules/commands/repair.lua b/modules/commands/repair.lua new file mode 100644 index 00000000..786abdde --- /dev/null +++ b/modules/commands/repair.lua @@ -0,0 +1,37 @@ +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 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 and entity.force == player.force 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 + ghost.revive() + 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 + local x = entity.position.x-center.x + local y = entity.position.y-center.y + if entity.health and x^2+y^2 <= range2 then + entity.health = max_time_to_live + end + end + end +end) \ No newline at end of file From 6af7bc10745b2cbe2bc6642b771fed371e754e4b Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 23:20:19 +0100 Subject: [PATCH 13/18] Added Player Auto Color --- config/preset_player_colours.lua | 36 +++++++++++++++++++ modules/addons/random-player-colours.lua | 27 ++++++++++++++ .../Commands}/repair/control.lua | 0 .../Commands}/repair/softmod.json | 0 .../Commands}/repair/src/tempban.lua | 0 .../{ => DONE}/PlayerAutoColor/control.lua | 0 .../{ => DONE}/PlayerAutoColor/softmod.json | 0 7 files changed, 63 insertions(+) create mode 100644 config/preset_player_colours.lua create mode 100644 modules/addons/random-player-colours.lua rename old/modules/{ExpGamingCommands => DONE/Commands}/repair/control.lua (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/repair/softmod.json (100%) rename old/modules/{ExpGamingCommands => DONE/Commands}/repair/src/tempban.lua (100%) rename old/modules/{ => DONE}/PlayerAutoColor/control.lua (100%) rename old/modules/{ => DONE}/PlayerAutoColor/softmod.json (100%) diff --git a/config/preset_player_colours.lua b/config/preset_player_colours.lua new file mode 100644 index 00000000..8a15069e --- /dev/null +++ b/config/preset_player_colours.lua @@ -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} + } +} \ No newline at end of file diff --git a/modules/addons/random-player-colours.lua b/modules/addons/random-player-colours.lua new file mode 100644 index 00000000..df5b190b --- /dev/null +++ b/modules/addons/random-player-colours.lua @@ -0,0 +1,27 @@ +local Colours = require 'resources.colour_presets' +local Game = require 'utils.game' +local Event = require 'utils.events' +local config = require 'config.preset_player_colours' +local Global = require 'utils.global' +require 'utils.table' + +Global.reigster(config,function(tbl) + config = tbl +end) + +local white = Colours.white +local black = Colours.black +Event.add(defines.events.on_player_created,function(event) + 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) \ No newline at end of file diff --git a/old/modules/ExpGamingCommands/repair/control.lua b/old/modules/DONE/Commands/repair/control.lua similarity index 100% rename from old/modules/ExpGamingCommands/repair/control.lua rename to old/modules/DONE/Commands/repair/control.lua diff --git a/old/modules/ExpGamingCommands/repair/softmod.json b/old/modules/DONE/Commands/repair/softmod.json similarity index 100% rename from old/modules/ExpGamingCommands/repair/softmod.json rename to old/modules/DONE/Commands/repair/softmod.json diff --git a/old/modules/ExpGamingCommands/repair/src/tempban.lua b/old/modules/DONE/Commands/repair/src/tempban.lua similarity index 100% rename from old/modules/ExpGamingCommands/repair/src/tempban.lua rename to old/modules/DONE/Commands/repair/src/tempban.lua diff --git a/old/modules/PlayerAutoColor/control.lua b/old/modules/DONE/PlayerAutoColor/control.lua similarity index 100% rename from old/modules/PlayerAutoColor/control.lua rename to old/modules/DONE/PlayerAutoColor/control.lua diff --git a/old/modules/PlayerAutoColor/softmod.json b/old/modules/DONE/PlayerAutoColor/softmod.json similarity index 100% rename from old/modules/PlayerAutoColor/softmod.json rename to old/modules/DONE/PlayerAutoColor/softmod.json From cc64613f418e721e7a8e85ff398e5a0c2c5a5149 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 23:29:21 +0100 Subject: [PATCH 14/18] Bug Fix Round One --- config/file_loader.lua | 7 +++++++ expcore/commands.lua | 2 +- modules/addons/compilatron.lua | 10 +++++----- modules/addons/random-player-colours.lua | 2 +- modules/commands/clear-inventory.lua | 2 +- modules/commands/spawn.lua | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config/file_loader.lua b/config/file_loader.lua index 7a85b3cc..790aa6c6 100644 --- a/config/file_loader.lua +++ b/config/file_loader.lua @@ -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 diff --git a/expcore/commands.lua b/expcore/commands.lua index 9a8ef7f9..27257c9a 100644 --- a/expcore/commands.lua +++ b/expcore/commands.lua @@ -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 diff --git a/modules/addons/compilatron.lua b/modules/addons/compilatron.lua index 29fc2bfe..ef81281d 100644 --- a/modules/addons/compilatron.lua +++ b/modules/addons/compilatron.lua @@ -31,17 +31,17 @@ local callback = ent.surface.create_entity( {name = 'compi-speech-bubble', text = messages[name][msg_number], position = {0, 0}, source = ent} ) - Public.global.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(Public.global.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 = Public.global.current_messages[name] + local current_message = Public.current_messages[name] local msg_number local message if current_message ~= nil then @@ -71,12 +71,12 @@ function Public.add_compilatron(entity, name) if name == nil then return end - Public.global.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} ) - Public.global.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) diff --git a/modules/addons/random-player-colours.lua b/modules/addons/random-player-colours.lua index df5b190b..3a6fc2c1 100644 --- a/modules/addons/random-player-colours.lua +++ b/modules/addons/random-player-colours.lua @@ -1,4 +1,4 @@ -local Colours = require 'resources.colour_presets' +local Colours = require 'resources.color_presets' local Game = require 'utils.game' local Event = require 'utils.events' local config = require 'config.preset_player_colours' diff --git a/modules/commands/clear-inventory.lua b/modules/commands/clear-inventory.lua index 28fd9d35..0b8a8d26 100644 --- a/modules/commands/clear-inventory.lua +++ b/modules/commands/clear-inventory.lua @@ -1,4 +1,4 @@ -local Commands = 'expcore.commands' +local Commands = require 'expcore.commands' local move_items = ext_require('expcore.common','move_items') require 'config.command_parse_roles' diff --git a/modules/commands/spawn.lua b/modules/commands/spawn.lua index 0b923222..027c85f3 100644 --- a/modules/commands/spawn.lua +++ b/modules/commands/spawn.lua @@ -13,7 +13,7 @@ end Commands.new_command('go-to-spawn','Teleport to spawn') :add_param('player',true,'player-role-alive') -:add_defaults{ +:set_defaults{ player=function(player) if player.connected and player.character and player.character.health > 0 then return player From 745e31b7e729a80b3b150abf7d87bdbf02b990dd Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 18 Apr 2019 23:40:55 +0100 Subject: [PATCH 15/18] Added Commands to roles --- config/roles.lua | 33 +++++++++++++++++++----- modules/addons/random-player-colours.lua | 5 ++-- modules/commands/warnings.lua | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/config/roles.lua b/config/roles.lua index b203201d..8faf42e9 100644 --- a/config/roles.lua +++ b/config/roles.lua @@ -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-warning', + '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{ } @@ -111,6 +128,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 +157,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 @@ -151,12 +173,11 @@ 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 diff --git a/modules/addons/random-player-colours.lua b/modules/addons/random-player-colours.lua index 3a6fc2c1..0e347997 100644 --- a/modules/addons/random-player-colours.lua +++ b/modules/addons/random-player-colours.lua @@ -1,17 +1,18 @@ local Colours = require 'resources.color_presets' local Game = require 'utils.game' -local Event = require 'utils.events' +local Event = require 'utils.event' local config = require 'config.preset_player_colours' local Global = require 'utils.global' require 'utils.table' -Global.reigster(config,function(tbl) +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] diff --git a/modules/commands/warnings.lua b/modules/commands/warnings.lua index c4fe12f1..e4b0cb2c 100644 --- a/modules/commands/warnings.lua +++ b/modules/commands/warnings.lua @@ -46,7 +46,7 @@ Commands.new_command('get-warnings','Gets the number of warnings a player has. I end end) -Commands.new_command('clear-warnigns','Clears all warnings (and script warnings) from a player') +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(player,player.name) From 37e040c09353295c77cb33210b169de184c7aa35 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 19 Apr 2019 00:11:44 +0100 Subject: [PATCH 16/18] Bug Fixing Round Two --- expcore/commands.lua | 4 ++-- expcore/common.lua | 2 +- locale/en/commands.cfg | 3 ++- modules/commands/repair.lua | 19 +++++++++++++------ modules/commands/reports.lua | 2 +- modules/commands/roles.lua | 4 ++-- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/expcore/commands.lua b/expcore/commands.lua index 27257c9a..c96dcce4 100644 --- a/expcore/commands.lua +++ b/expcore/commands.lua @@ -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) diff --git a/expcore/common.lua b/expcore/common.lua index 096e0eeb..2390c5ef 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -524,7 +524,7 @@ end function Public.format_chat_player_name(player,raw_string) player = Game.get_player_from_any(player) local player_name = player and player.name or '' - local player_chat_colour = player and player.chat_color or Colors.white + 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 diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index b35ff51f..f987582c 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -34,4 +34,5 @@ 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. \ No newline at end of file +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. \ No newline at end of file diff --git a/modules/commands/repair.lua b/modules/commands/repair.lua index 786abdde..660ec6eb 100644 --- a/modules/commands/repair.lua +++ b/modules/commands/repair.lua @@ -6,6 +6,8 @@ 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 @@ -13,12 +15,13 @@ Commands.new_command('repair','Repairs entities on your force around you') 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 and entity.force == player.force then + 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 - ghost.revive() + revive_count = revive_count+1 + if not config.disallow[ghost.ghost_name] then ghost.revive() end end end end @@ -27,11 +30,15 @@ Commands.new_command('repair','Repairs entities on your force around you') if config.allow_heal_entities then local entities = surface.find_entities_filtered({area=area,force=player.force}) for _,entity in pairs(entities) do - local x = entity.position.x-center.x - local y = entity.position.y-center.y - if entity.health and x^2+y^2 <= range2 then - entity.health = max_time_to_live + 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) \ No newline at end of file diff --git a/modules/commands/reports.lua b/modules/commands/reports.lua index f1c5c670..a1b83e45 100644 --- a/modules/commands/reports.lua +++ b/modules/commands/reports.lua @@ -9,7 +9,7 @@ Commands.new_command('report','Reports a player and notifies moderators') input = Commands.parse('player',input,player,reject) if not input then return end if Roles.player_has_flag(player,'report-immune') then - return reject{'exp-command.report-player-immune'} + return reject{'exp-commands.report-player-immune'} else return input end diff --git a/modules/commands/roles.lua b/modules/commands/roles.lua index e19d521c..792447c9 100644 --- a/modules/commands/roles.lua +++ b/modules/commands/roles.lua @@ -40,7 +40,7 @@ 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 @@ -49,7 +49,7 @@ Commands.new_command('list-roles','Lists all roles in they correct order') local role_name = format_chat_colour_localized(role.name,colour) if index == 1 then message = {'exp-commands.roles-list',role_name} - if action_player ~= '' then + 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 From 53a74b96e3cd056a2ede8c5527198e3483fc7ca9 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 19 Apr 2019 14:06:08 +0100 Subject: [PATCH 17/18] Bug Fixing Round 3 --- .luacheckrc | 1002 +++++++++++++++++++++++++++ config/command_parse_roles.lua | 9 +- config/roles.lua | 4 +- expcore/common.lua | 4 +- expcore/roles.lua | 4 + locale/en/addons.cfg | 3 +- modules/addons/jail-control.lua | 2 +- modules/addons/reports-control.lua | 9 +- modules/addons/warnings-control.lua | 7 +- modules/commands/jail.lua | 5 +- modules/commands/reports.lua | 7 +- modules/commands/warnings.lua | 4 +- 12 files changed, 1042 insertions(+), 18 deletions(-) create mode 100644 .luacheckrc diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 00000000..c3e0c5cf --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,1002 @@ +------------------------------------------------------------------------------- +--[LICENSE]-- +------------------------------------------------------------------------------- +-- .luacheckrc +-- This file is free and unencumbered software released into the public domain. +-- +-- Anyone is free to copy, modify, publish, use, compile, sell, or +-- distribute this file, either in source code form or as a compiled +-- binary, for any purpose, commercial or non-commercial, and by any +-- means. +-- +-- In jurisdictions that recognize copyright laws, the author or authors +-- of this file dedicate any and all copyright interest in the +-- software to the public domain. We make this dedication for the benefit +-- of the public at large and to the detriment of our heirs and +-- successors. We intend this dedication to be an overt act of +-- relinquishment in perpetuity of all present and future rights to this +-- software under copyright law. +-- +-- THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +-- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +-- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +-- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +-- OTHER DEALINGS IN THE SOFTWARE. +-- +-- For more information, please refer to +-- ]] + +------------------------------------------------------------------------------- +--[.luacheckrc]-- Current Factorio Version .16 +------------------------------------------------------------------------------- +-- Set up the the standards for this file. +files['.luacheckrc'] = { + std = 'lua52c', + globals = {'files', 'exclude_files', 'not_globals', 'stds', 'std', 'max_line_length', 'ignore', 'quiet', "max_cyclomatic_complexity", "codes"}, + max_line_length = false --turn of line length warnings for this file +} + +------------------------------------------------------------------------------- +--[Set Defaults]-- +------------------------------------------------------------------------------- +local LINE_LENGTH = false -- It is 2017 limits on length are a waste +local IGNORE = {'21./%w+_$', '21./^_%w+$', '213/[ijk]', '213/index', '213/key'} +local NOT_GLOBALS = {'coroutine', 'io', 'socket', 'dofile', 'loadfile'} -- These globals are not available to the factorio API + +local STD_CONTROL = 'lua52c+factorio+factorio_control+stdlib+factorio_defines' +local STD_DATA = 'lua52c+factorio+factorio_data+stdlib+stdlib_data+factorio_defines' + +-- In a perfect world these would be STD_DATA and STD_CONTROL (mostly) +local STD_BASE_DATA = 'lua52c+factorio+factorio_data+factorio_defines+factorio_base_data' +local STD_BASE_CONTROL = 'lua52c+factorio+factorio_control+factorio_defines+factorio_base_control' + +------------------------------------------------------------------------------- +--[Assume Factorio Control stage as default]-- +------------------------------------------------------------------------------- +std = STD_CONTROL +max_line_length = LINE_LENGTH + +not_globals = NOT_GLOBALS +ignore = IGNORE +quiet = 1 -- pass -q option +max_cyclomatic_complexity = 75 +codes = true + +--List of files and directories to exclude +exclude_files = { + --Ignore special folders + '**/.*/*', --Ignore if path starts with . + '**/mod/stdlib/', --Ignore from symlinked + '**/vendor/', + + --Ignore development mods + '**/combat-tester/', + '**/test-maker/', + '**/trailer/', +} + +------------------------------------------------------------------------------- +--[Mod Prototypes]-- +------------------------------------------------------------------------------- +--Set default prototype files +files['**/data.lua'].std = STD_DATA +files['**/data-updates.lua'].std = STD_DATA +files['**/data-final-fixes.lua'].std = STD_DATA +files['**/settings.lua'].std = STD_DATA +files['**/settings-updates.lua'].std = STD_DATA +files['**/settings-final-fixes.lua'].std = STD_DATA +files['**/prototypes/'].std = STD_DATA +files['**/settings/'].std = STD_DATA + +------------------------------------------------------------------------------- +--[Base]-- +------------------------------------------------------------------------------- +--Find and replace ignores *.cfg, migrations, *.txt, control.lua, *.json, trailer, scenarios, campaigns, *.glsl + +local base_scenarios = { + std = STD_BASE_CONTROL .. '+factorio_base_scenarios+factorio_base_story', + --Ignore these, Klonan is on his own! + --ignore = {'212/event', '111', '112', '113', '211', '212', '213', '311', '411', '412', '421', '422', '423', '431', '432', '512'} + ignore = {'...'} +} +files['**/base/scenarios/'] = base_scenarios +files['**/base/tutorials/'] = base_scenarios +files['**/base/campaigns/'] = base_scenarios +files['**/wip-scenario/'] = base_scenarios + +files['**/base/migrations/'] = {std = STD_BASE_CONTROL} + +files['**/core/lualib/'] = {std = STD_BASE_CONTROL} +files['**/core/lualib/util.lua'] = {globals = {'util', 'table'}, ignore = {'432/object'}} +files['**/core/lualib/silo-script.lua'] = {globals = {'silo_script'}, ignore = {'4../player'}} +files['**/core/lualib/production-score.lua'] = {globals = {'production_score', 'get_price_recursive'}, ignore = {'4../player'}} +files['**/core/lualib/story*'] = {std = '+factorio_base_story', ignore = {'42./k', '42./filter'}} +files['**/core/lualib/mod-gui.lua'] = {globals = {'mod_gui'}} +files['**/core/lualib/camera.lua'] = {globals = {'camera'}} +files['**/core/lualib/builder.lua'] = {globals = {'Builder', 'builder', 'action', 'down', 'right'}} + +files['**/core/lualib/bonus-gui-ordering/'] = {std = STD_BASE_DATA} +files['**/core/lualib/dataloader.lua'] = {globals = {'data'}} +files['**/core/lualib/circuit-connector-*'] = {std = STD_BASE_DATA..'+factorio_circuit_connector_generated'} +files['**/core/lualib/bonus-gui-ordering.lua'] = {globals = {'bonus_gui_ordering'}} + +files['**/base/prototypes/'] = {std = STD_BASE_DATA} +files['**/core/prototypes/'] = {std = STD_BASE_DATA} +files['**/core/prototypes/noise-programs.lua'] = {ignore = {'212/x', '212/y', '212/tile', '212/map'}} + +------------------------------------------------------------------------------- +--[Set STDLIB project modules]-- +------------------------------------------------------------------------------- +local stdlib_control = { + std = 'lua52c+factorio+factorio_control+stdlib+factorio_defines', + max_line_length = LINE_LENGTH +} + +local stdlib_data = { + std = 'lua52c+factorio+factorio_data+stdlib+factorio_defines', + max_line_length = LINE_LENGTH +} + +-- Assume control stage for stdlib +files['**/stdlib/'] = stdlib_control + +files['**/stdlib/utils/math.lua'].std = 'lua52c' +files['**/stdlib/utils/string.lua'].std = 'lua52c' +files['**/stdlib/utils/table.lua'].std = 'lua52c' +files['**/stdlib/utils/iterator.lua'].std = 'lua52c' +files['**/stdlib/utils/is.lua'].std = 'lua52c' + +-- STDLIB data files +files['**/stdlib/data/'] = stdlib_data +files['**/creative'].ignore = {'...'} + +-- STDLIB Busted Spec +files['**/spec/**'] = { + globals = {'serpent', 'log', 'SLOG', 'RESET'}, + std = 'lua52c+busted+factorio_defines+factorio_control+stdlib' +} + + +------------------------------------------------------------------------------- +--[STDS FACTORIO]-- +------------------------------------------------------------------------------- +stds.factorio = { + --Set the read only variables + read_globals = { + -- @log@: Gives writing access to Factorio's logger instance. + "log", + -- @serpent@: Lua serializer and pretty printer. (https://github.com/pkulchenko/serpent) + "serpent", + -- @table_size@: Returns the number of elements inside an LUA table + "table_size", + util = { + fields = { + "by_pixel", "distance", "findfirstentity", "positiontostr", "formattime", "moveposition", "oppositedirection", + "ismoduleavailable", "multiplystripes", "format_number", "increment", "color", "conditional_return", + "add_shift", "merge", "premul_color", "encode", "decode", + table = { + fields = { + "compare", "deepcopy" + }, + }, + }, + }, + table = { + fields = { + "compare", "deepcopy" + }, + }, + }, +} + +stds.factorio_control = { + read_globals = { + + -- @commands@: + commands = { + fields = { + "add_command", "commands", "game_commands", "remove_command", + }, + }, + + -- @settings@: + settings = { + fields = { + "get_player_settings", + startup = {read_only = false, other_fields = true}, + global = {read_only = false, other_fields = true}, + player = {read_only = false, other_fields = true}, + }, + }, + + -- @script@: Provides an interface for registering event handlers. + -- (http://lua-api.factorio.com/latest/LuaBootstrap.html) + script = { + fields = { + "on_event", "on_nth_tick", "on_configuration_changed", "on_init", "on_load", "generate_event_name", + "raise_event", "get_event_handler", "mod_name", "get_event_order" + }, + }, + + -- @remote@: Allows inter-mod communication by providing a repository of interfaces that is shared by all mods. + -- (http://lua-api.factorio.com/latest/LuaRemote.html) + remote = { + fields = { + "add_interface", "remove_interface", "call", "interfaces" + }, + }, + + -- @game@: Main object through which most of the API is accessed. + -- It is, however, not available inside handlers registered with @script.on_load@. + -- (http://lua-api.factorio.com/latest/LuaGameScript.html) + game ={ + other_fields = true, + read_only = false, + fields = { + "set_game_state", "get_entity_by_tag", "show_message_dialog", "disable_tips_and_tricks", "is_demo", "reload_script", + "save_atlas", "check_consistency", "regenerate_entity", "take_screenshot", "write_file", "remove_path", + "remove_offline_players", "force_crc", "merge_forces", "player", "server_save", "delete_surface", "disable_replay", + "direction_to_string", "print", "tick", "finished", "difficulty", + speed = { + --rw + read_only = false, + }, + player = { + --luaPlayer + --The player typing at the console, nil in all other cases + read_only = false, + other_fields = true, + }, + players = { + --array of luaPlayer + read_only = false, + other_fields = true, + }, + connected_players = { + --array of luaPlayer + read_only = false, + other_fields = true, + }, + surfaces = { + --array of luaSurface + read_only = false, + other_fields = true, + }, + create_surface = { + --luaSurface + read_only = false, + other_fields = true, + }, + forces = { + --array of luaForce + read_only = false, + other_fields = true, + }, + create_force = { + --luaForce + read_only = false, + other_fields = true, + }, + entity_prototypes = { + --string dictionary - > luaEntityPrototype + read_only = true, + other_fields = true + }, + item_prototypes = { + --string dictionary - > luaItemPrototype + read_only = true, + other_fields = true + }, + fluid_prototypes = { + --string dictionary - > luaFluidPrototype + read_only = true, + other_fields = true + }, + tile_prototypes = { + --string dictionary - > luaTilePrototype + read_only = true, + other_fields = true + }, + equipment_prototypes = { + --string dictionary - > luaEquipmentPrototype + read_only = true, + other_fields = true + }, + recipe_prototypes = { + --string dictionary - > luaRecipePrototype + read_only = true, + other_fields = true + }, + technology_prototypes = { + --string dictionary - > luaTechnologyPrototype + read_only = true, + other_fields = true + }, + damage_prototypes = { + --string dictionary - > luaDamagePrototype + read_only = true, + other_fields = true + }, + virtual_signal_prototypes = { + --string dictionary - > luaVirtualSignalPrototype + read_only = true, + other_fields = true + }, + equipment_grid_prototypes = { + --string dictionary - > luaEquipmentGridPrototype + read_only = true, + other_fields = true + }, + decorative_prototypes = { + --string dictionary -> LuaDecorativePrototype + read_only = true, + other_fields = true + }, + map_settings = { + --custom -> mapsettings + read_only = false, + other_fields = true + }, + active_mods = { + --string dictionary -> string version + read_only = true, + other_fields = true + }, + permissions = { + read_only = true, + other_fields = true + }, + backer_names = { + read_only = true, + other_fields = true + } + }, + }, + }, + + globals = { + -- @global@: The global dictionary, useful for storing data persistent across a save-load cycle. + -- Writing access is given to the mod-id field (for mod-wise saved data). + -- (http://lua-api.factorio.com/latest/Global.html) + "global", + + -- @MOD@: Keep it organized, use this variable for anything that "NEEDS" to be global for some reason. + "MOD" + }, +} + +stds.factorio_data = { + + read_globals = { + data = { + fields = { + raw = { + other_fields = true, + read_only = false + }, + "extend", "is_demo" + }, + }, + + settings = { + fields = { + "startup", "global", "player", + }, + }, + + --Popular mods + angelsmods = { + other_fields = true + }, + + bobmods = { + other_fields = true + }, + + mods = { + other_fields = true + } + } +} + +------------------------------------------------------------------------------- +--[Factorio Data]-------------------------------------------------------------- +------------------------------------------------------------------------------- +stds.factorio_base_control = { + read_globals = {"silo_script", "mod_gui", "camera"} +} + +stds.factorio_base_scenarios = { + globals = { + "check_automate_science_packs_advice", "check_research_hints", "check_supplies", "manage_attacks", "all_dead", + "on_win", "difficulty_number", "init_attack_data", "handle_attacks", "count_items_in_container", "progress", "scanned", + "check_light", "check_machine_gun", "level", "story_table", + + "tightspot_prices", "tightspot_make_offer", "tightspot_init", "tightspot_get_required_balance", + "tightspot_init_level", "tightspot_init_spending_frame", "tightspot_init_progress_frame", "tightspot_update_progress", "tightspot_update_spending", + "tightspot_get_missing_to_win", "tightspot_sell_back", "tightspot_start_level", "tightspot_show_level_description", "tightspot_update_speed_label", + "map_ignore", "tightspot_check_level", "land_price", + + "transport_belt_madness_init", "transport_belt_madness_init_level", "transport_belt_madness_create_chests", "transport_belt_madness_fill_chests", + "transport_belt_madness_start_level", "map_ignore", "map_clear", "map_load", "map_save", "transport_belt_madness_show_level_description", + "transport_belt_madness_check_level", "transport_belt_madness_next_level", "transport_belt_madness_clear_level", "transport_belt_madness_contains_next_level", + + "restricted", "check_built_items", "result", "disable_combat_technologies", "apply_character_modifiers", "apply_combat_modifiers", "apply_balance", + "load_config", "starting_area_constant", "create_next_surface", "end_round", "prepare_next_round", "silo_died","choose_joining_gui", + "destroy_joining_guis", "create_random_join_gui", "create_auto_assign_gui", "create_pick_join_gui", "create_config_gui", "make_config_table", "default", + "make_team_gui", "make_team_gui_config", "add_team_button_press", "trash_team_button_press", "remove_team_from_team_table", "add_team_to_team_table", + "set_teams_from_gui", "on_team_button_press", "make_color_dropdown", "create_balance_option", "create_disable_frame", "disable_frame", "parse_disabled_items", + "set_balance_settings", "config_confirm", "parse_config_from_gui", "get_color", "roll_starting_area", "delete_roll_surfaces", "auto_assign", + "destroy_config_for_all", "prepare_map", "set_evolution_factor", "update_players_on_team_count", "random_join", "init_player_gui", + "destroy_player_gui", "objective_button_press", "admin_button_press", "admin_frame_button_press", "diplomacy_button_press", "update_diplomacy_frame", + "diplomacy_frame_button_press", "team_changed_diplomacy", "diplomacy_check_press", "get_stance", "give_inventory", "setup_teams", "disable_items_for_all", + "set_random_team", "set_diplomacy", "create_spawn_positions", "set_spawn_position", "set_team_together_spawns", "chart_starting_area_for_force_spawns", + "check_starting_area_chunks_are_generated", "check_player_color", "check_round_start", "clear_starting_area_enemies", "check_no_rush_end", "check_no_rush_players", + "finish_setup", "chart_area_for_force", "setup_start_area_copy", "update_copy_progress", "update_progress_bar", "copy_paste_starting_area_tiles", + "copy_paste_starting_area_entities", "create_silo_for_force", "setup_research", "on_chunk_generated", "get_distance_to_nearest_spawn", + "create_wall_for_force", "fpn", "give_items", "create_item_frame", "create_technologies_frame", "create_cheat_frame", "create_day_frame", + "time_modifier", "points_per_second_start", "points_per_second_level_subtract", "levels", "update_info", "get_time_left", "update_time_left", + "on_joined", "make_frame", "update_frame", "update_table", "calculate_task_item_multiplayer", "setup_config", "select_from_probability_table", + "select_inventory", "select_equipment", "select_challange_type", "save_round_statistics", "start_challenge", "create_teams", "set_areas", + "decide_player_team", "set_teams", "refresh_leaderboard", "set_player", "generate_technology_list", "generate_research_task","setup_unlocks", + "check_technology_progress", "generate_production_task", "generate_shopping_list_task", "set_gui_flow_table", "create_visibility_button", + "check_item_lists", "update_task_gui", "check_end_of_round", "end_round_gui_update", "try_to_check_victory", "update_gui", "check_start_round", + "check_start_set_areas", "check_start_setting_entities", "check_set_areas", "check_clear_areas", "check_chests", "check_chests_shopping_list", + "check_chests_production", "check_input_chests", "fill_input_chests", "check_victory", "shopping_task_finished", "calculate_force_points", + "update_research_task_table", "update_production_task_table", "update_shopping_list_task_table", "create_joined_game_gui", "pre_ending_round", + "player_ending_prompt", "update_end_timer", "update_begin_timer", "team_finished", "save_points_list", "give_force_players_points", + "update_winners_list", "set_spectator", "set_character", "give_starting_inventory", "give_equipment", "shuffle_table", "format_time", + "spairs", "fill_leaderboard", "create_grid", "simple_entities", "save_map_data", "clear_map", "create_tiles", "recreate_entities", + "map_sets", "give_points", "init_forces", "init_globals", "init_unit_settings", "check_next_wave", "next_wave", "calculate_wave_power", + "wave_end", "make_next_spawn_tick", "check_spawn_units", "get_wave_units", "spawn_units", "randomize_ore", "set_command", "command_straglers", + "unit_config", "make_next_wave_tick", "time_to_next_wave", "time_to_wave_end", "rocket_died", "unit_died", "get_bounty_price", "setup_waypoints", + "insert_items", "give_starting_equipment", "give_spawn_equipment", "next_round_button_visible", "gui_init", "create_wave_frame", "create_money_frame", + "create_upgrade_gui", "update_upgrade_listing", "upgrade_research", "get_upgrades", "get_money", "update_connected_players", "update_round_number", + "set_research", "set_recipes", "check_deconstruction", "check_blueprint_placement", "loop_entities", "experiment_items", + "setup", "story_gui_click", "clear_surface", "add_run_trains_button", "puzzle_condition", "basic_signals", + "loop_trains", "Y_offset", "ghosts_1", "ghosts_2", "required_path", "through_wall_path", "count", "check_built_real_rail", + "current_ghosts_count", "other", "rails", "set_rails", "straight_section", "late_entities", "entities", "stop", + "get_spawn_coordinate", + + --tutorials + "intermission", "create_entities_on_tick", "on_player_created", "required_count", "non_player_entities", "clear_rails", + "chest", "damage", "furnace", "init_prototypes", "build_infi_table", "junk", "update_player_tags", "time_left", "team_production", + "create_task_frame", "create_visibilty_buttons", "update_leaderboard", "in_in_area" + } +} + +stds.factorio_base_data = { + globals = { + --Style + "make_cursor_box", "make_full_cursor_box", + "default_container_padding", "default_orange_color", "default_light_orange_color", "warning_red_color", + "achievement_green_color", "achievement_tan_color", "orangebuttongraphcialset", "bluebuttongraphcialset", + "bonus_gui_ordering", "trivial_smoke", "technology_slot_base_width", "technology_slot_base_height", "default_frame_font_vertical_compensation", + + --Belts + "transport_belt_connector_frame_sprites", "transport_belt_circuit_wire_connection_point", "transport_belt_circuit_wire_max_distance", + "transport_belt_circuit_connector_sprites", "ending_patch_prototype", "basic_belt_horizontal", "basic_belt_vertical", + "basic_belt_ending_top", "basic_belt_ending_bottom", "basic_belt_ending_side", "basic_belt_starting_top", "basic_belt_starting_bottom", + "basic_belt_starting_side", "fast_belt_horizontal", "fast_belt_vertical", "fast_belt_ending_top", "fast_belt_ending_bottom", + "fast_belt_ending_side", "fast_belt_starting_top", "fast_belt_starting_bottom", "fast_belt_starting_side", "express_belt_horizontal", + "express_belt_vertical", "express_belt_ending_top", "express_belt_ending_bottom", "express_belt_ending_side", "express_belt_starting_top", + "express_belt_starting_bottom", "express_belt_starting_side", + + --Circuit Connectors + "circuit_connector_definitions", "default_circuit_wire_max_distance", "inserter_circuit_wire_max_distance", + "universal_connector_template", "belt_connector_template", "belt_frame_connector_template", "inserter_connector_template", + + --Inserter Circuit Connectors + "inserter_circuit_wire_max_distance", "inserter_default_stack_control_input_signal", + + --Sounds/beams + "make_heavy_gunshot_sounds", "make_light_gunshot_sounds", "make_laser_sounds", + + --Gun/Laser + "gun_turret_extension", "gun_turret_extension_shadow", "gun_turret_extension_mask", "gun_turret_attack", + "laser_turret_extension", "laser_turret_extension_shadow", "laser_turret_extension_mask", + + --Pipes + "pipecoverspictures", "pipepictures", "assembler2pipepictures", "assembler3pipepictures", "make_heat_pipe_pictures", + + --Combinators + "generate_arithmetic_combinator", "generate_decider_combinator", "generate_constant_combinator", + + --Rail + "destroyed_rail_pictures", "rail_pictures", "rail_pictures_internal", "standard_train_wheels", "drive_over_tie", + "rolling_stock_back_light", "rolling_stock_stand_by_light", + + --Enemies + "make_enemy_autoplace", "make_enemy_spawner_autoplace", "make_enemy_worm_autoplace", + "make_spitter_attack_animation", "make_spitter_run_animation", "make_spitter_dying_animation", + "make_spitter_attack_parameters", "make_spitter_roars", "make_spitter_dying_sounds", + "make_spawner_idle_animation", "make_spawner_die_animation", + "make_biter_run_animation", "make_biter_attack_animation", "make_biter_die_animation", + "make_biter_roars", "make_biter_dying_sounds", "make_biter_calls", + "make_worm_roars", "make_worm_dying_sounds", "make_worm_folded_animation", "make_worm_preparing_animation", + "make_worm_prepared_animation", "make_worm_attack_animation", "make_worm_die_animation", + + --Other + "tile_variations_template", "make_water_autoplace_settings", + "make_unit_melee_ammo_type", "make_trivial_smoke", "make_4way_animation_from_spritesheet", "flying_robot_sounds", + "productivitymodulelimitation", "crash_trigger", "capsule_smoke", "make_beam", "playeranimations", + "make_blood_tint", "make_shadow_tint", + + --tiles + "water_transition_template", "make_water_transition_template", "water_autoplace_settings", "water_tile_type_names", + "patch_for_inner_corner_of_transition_between_transition", + } +} + +stds.factorio_base_story = { + globals = { + "story_init_helpers", "story_update_table", "story_init", "story_update", "story_on_tick", "story_add_update", + "story_remove_update", "story_jump_to", "story_elapsed", "story_elapsed_check", "story_show_message_dialog", + "set_goal", "player_set_goal", "on_player_joined", "flash_goal", "set_info", "player_set_info", "export_entities", + "list", "recreate_entities", "entity_to_connect", "limit_camera", "find_gui_recursive", "enable_entity_export", + "add_button", "on_gui_click", "set_continue_button_style", "add_message_log", "story_add_message_log", + "player_add_message_log", "message_log_frame", "message_log_scrollpane", "message_log_close_button", + "message_log_table", "toggle_message_log_button", "toggle_objective_button", "message_log_init", + "add_gui_recursive", "add_toggle_message_log_button", "add_toggle_objective_button", "mod_gui", + "flash_message_log_button", "flash_message_log_on_tick", "story_gui_click", "story_points_by_name", "story_branches", + "player", "surface", "deconstruct_on_tick", "recreate_entities_on_tick", "flying_congrats", "story_table" + } +} + +stds.factorio_circuit_connector_generated = { + globals = { + 'default_circuit_wire_max_distance', 'circuit_connector_definitions', 'universal_connector_template', + 'belt_connector_template', 'belt_frame_connector_template', 'inserter_connector_template', 'inserter_connector_template', + 'inserter_circuit_wire_max_distance', 'inserter_default_stack_control_input_signal', 'transport_belt_connector_frame_sprites', + 'transport_belt_circuit_wire_max_distance', + } +} + +--(( STDLIB ))-- +stds.stdlib = { + read_globals = { + table = { + fields = { + "map", "avg", "count_keys", "sum", "max", "remove", "insert", "invert", "first", "sort", "compare", "maxn", "any", "array_to_dictionary", + "each", "flatten", "keys", "filter", "remove_keys", "flexcopy", "find", "fullcopy", "values", "pack", "deepcopy", "concat", "clear", "min", + "is_empty", "merge", "size", "dictionary_merge", "unpack", "last" + }, + }, + string = { + fields = { + "is_space", "is_empty", "match", "title", "upper", "gmatch", "trim", "split", "len", "ordinal_suffix", "dump", "shorten", "reverse", + "ends_with", "byte", "starts_with", "join", "is_alpha", "lower", "is_upper", "is_digit", "is_alnum", "rjust", "center", "ljust", "format", + "char", "is_lower", "contains", "gsub", "find", "rep", "sub" + }, + }, + math = { + fields = { + "asin", "max", "modf", "midrange_mean", "pow", "ldexp", "maxuint16", "fmod", "round_to", "randomseed", "huge", "harmonic_mean", "tan", + "maxint32", "quadratic_mean", "pi", "energetic_mean", "minint8", "frexp", "generalized_mean", "rad", "sin", "sinh", "min", "geometric_mean", + "atan", "avg", "cosh", "maxint8", "arithmetic_mean", "exp", "sum", "round", "maxuint64", "minint64", "ceil", "maxint64", "atan2", "floor_to", + "floor", "log", "maxint16", "minint16", "tanh", "acos", "deg", "cos", "log10", "maxuint8", "abs", "weighted_mean", "random", "maxuint32", + "sqrt", "minint32" + } + }, + }, + globals = { + "prequire", "rawtostring", "traceback", "inspect", "serpent", "inline_if", + "GAME", "AREA", "POSITION", "TILE", "SURFACE", "CHUNK", "COLOR", "ENTITY", "INVENTORY", "RESOURCE", "CONFIG", "LOGGER", "QUEUE", + "EVENT", "GUI", "PLAYER", "FORCE", + "_STDLIB_NO_DEFINES_COLOR", "_STDLIB_NO_DEFINES_TIME", "_STDLIB_NO_STRING", "_STDLIB_NO_TABLE", "_STDLIB_NO_MATH" + } +} + +stds.stdlib_control = { +} + +stds.stdlib_data = { + globals = { + 'DATA', 'RECIPE', 'ITEM', 'FLUID', 'ENTITY', 'TECHNOLOGY', 'CATEGORY' + } +} --)) + +--(( FACTORIO DEFINES ))-- +stds.factorio_defines = { + globals = {"creative_mode_defines"}, + read_globals = { + defines = { + fields = { + events = { + fields = { + "on_tick", "on_gui_click", "on_gui_text_changed", "on_gui_checked_state_changed", "on_entity_died", "on_entity_damaged", "on_picked_up_item", + "on_built_entity", "on_sector_scanned", "on_player_mined_item", "on_put_item", "on_rocket_launched", "on_pre_player_mined_item", "on_chunk_generated", + "on_player_crafted_item", "on_robot_built_entity", "on_robot_pre_mined", "on_robot_mined", "on_research_started", "on_research_finished", + "on_player_rotated_entity", "on_marked_for_deconstruction", "on_canceled_deconstruction", "on_trigger_created_entity", "on_train_changed_state", + "on_player_created", "on_resource_depleted", "on_player_driving_changed_state", "on_force_created", "on_forces_merging", "on_player_cursor_stack_changed", + "on_pre_entity_settings_pasted", "on_entity_settings_pasted", "on_player_main_inventory_changed", "on_player_quickbar_inventory_changed", + "on_player_tool_inventory_changed", "on_player_armor_inventory_changed", "on_player_ammo_inventory_changed", "on_player_gun_inventory_changed", + "on_player_placed_equipment", "on_player_removed_equipment", "on_pre_player_died", "on_player_died", "on_player_respawned", "on_player_joined_game", + "on_player_left_game", "on_player_built_tile", "on_player_mined_tile", "on_robot_built_tile", "on_robot_mined_tile", "on_player_selected_area", + "on_player_alt_selected_area", "on_player_changed_surface", "on_selected_entity_changed", "on_market_item_purchased", "on_player_dropped_item", + "on_biter_base_built", "on_player_changed_force", "on_entity_renamed", "on_gui_selection_state_changed", "on_runtime_mod_setting_changed", + "on_difficulty_settings_changed", "on_surface_created", "on_surface_deleted", "on_pre_surface_deleted", "on_player_mined_entity", "on_robot_mined_entity", + "on_train_created", "on_gui_elem_changed", "on_player_setup_blueprint", "on_player_deconstructed_area", "on_player_configured_blueprint", "on_console_chat", + "on_console_command", "on_player_removed", "on_player_used_capsule", "script_raised_built", "script_raised_destroy", "script_raised_revive", + "on_player_promoted", "on_player_demoted", "on_combat_robot_expired", "on_player_changed_position", "on_mod_item_opened", "on_gui_opened", + "on_gui_closed", "on_gui_value_changed", "on_player_muted", "on_player_unmuted", "on_player_cheat_mode_enabled", "on_player_cheat_mode_disabled", + "on_character_corpse_expired", "on_pre_ghost_deconstructed", "on_player_pipette", "on_player_display_resolution_changed", "on_player_display_scale_changed", + "on_pre_player_crafted_item", "on_player_cancelled_crafting", "on_chunk_charted", "on_technology_effects_reset", "on_land_mine_armed", "on_forces_merged", + "on_player_trash_inventory_changed", "on_pre_player_left_game" + }, + }, + alert_type = { + fields = { + "custom", "entity_destroyed", "entity_under_attack", "no_material_for_construction", + "no_storage", "not_enough_construction_robots", "not_enough_repair_packs", "turret_fire", + }, + }, + chain_signal_state = { + fields = { + "all_open", "none", "none_open", "partially_open", + }, + }, + chunk_generated_status = { + fields = { + "basic_tiles", "corrected_tiles", "custom_tiles", "entities", "nothing", "tiles", + }, + }, + circuit_condition_index = { + fields = { + "arithmetic_combinator", "constant_combinator", "decider_combinator", "inserter_circuit", + "inserter_logistic", "lamp", "offshore_pump", "pump", + }, + }, + circuit_connector_id = { + fields = { + "accumulator", "combinator_input", "combinator_output", "constant_combinator", "container", + "electric_pole", "inserter", "lamp", "offshore_pump", "programmable_speaker", "pump", + "rail_signal", "roboport", "storage_tank", "wall", + }, + }, + command = { + fields = { + "attack", "attack_area", "build_base", "compound", "go_to_location", "group", "wander", + }, + }, + compound_command = { + fields = { + "logical_and", "logical_or", "return_last", + }, + }, + control_behavior = { + fields = { + inserter = { + fields = { + circuit_mode_of_operation = { + fields = { + "enable_disable", "none", "read_hand_contents", "set_filters", "set_stack_size", + }, + }, + hand_read_mode = { + fields = { + "hold", "pulse", + } + }, + }, + }, + lamp = { + fields = { + circuit_mode_of_operation = { + fields = { + "use_colors", + } + }, + }, + }, + logistic_container = { + fields = { + circuit_mode_of_operation = { + fields = { + "send_contents", "set_requests", + } + }, + }, + }, + mining_drill = { + fields = { + resource_read_mode = { + fields = { + "entire_patch", "this_miner", + } + }, + }, + }, + roboport = { + fields = { + circuit_mode_of_operation = { + fields = { + "read_logistics", "read_robot_stats", + } + }, + }, + }, + train_stop = { + fields = { + circuit_mode_of_operation = { + fields = { + "enable_disable", "read_from_train", "send_to_train", + } + }, + }, + }, + type = { + fields = { + "accumulator", "arithmetic_combinator", "constant_combinator", "container", + "decider_combinator", "generic_on_off", "inserter", "lamp", "logistic_container", + "rail_signal", "roboport", "storage_tank", "train_stop", "transport_belt", + }, + }, + }, + }, + controllers = { + fields = { + "character", "ghost", "god", + }, + }, + deconstruction_item = { + fields = { + entity_filter_mode = { + fields = { + "blacklist", "whitelist", + }, + }, + tile_filter_mode = { + fields = { + "always", "never", "normal", "only", + } + }, + }, + }, + difficulty = { + fields = { + "easy", "hard", "normal", + }, + }, + difficulty_settings = { + fields = { + recipe_difficulty = { + fields = { + "expensive", "normal", + }, + }, + technology_difficulty = { + fields = { + "expensive", "normal", + } + }, + }, + }, + direction = { + fields = { + "east", "north", "northeast", "northwest", "south", "southeast", "southwest", "west", + }, + }, + distraction = { + fields = { + "by_anything", "by_damage", "by_enemy", "none", + }, + }, + group_state = { + fields = { + "attacking_distraction", "attacking_target", "finished", "gathering", "moving", + }, + }, + gui_type = { + fields = { + "achievement", "blueprint_library", "bonus", "controller", "entity", "equipment", "item", + "kills", "logistic", "none", "other_player", "permissions", "production", "research", + "trains", "tutorials", "custom", + }, + }, + input_action = { + fields = { + "add_permission_group", "alt_select_area", "alt_select_blueprint_entities", "begin_mining", + "begin_mining_terrain", "build_item", "build_rail", "build_terrain", "cancel_craft", + "cancel_deconstruct", "cancel_new_blueprint", "cancel_research", "change_active_item_group_for_crafting", + "change_active_item_group_for_filters", "change_active_quick_bar", "change_arithmetic_combinator_parameters", + "change_blueprint_book_record_label", "change_decider_combinator_parameters", "change_item_label", + "change_picking_state", "change_programmable_speaker_alert_parameters", "change_programmable_speaker_circuit_parameters", + "change_programmable_speaker_parameters", "change_riding_state", "change_shooting_state", + "change_single_blueprint_record_label", "change_train_stop_station", "change_train_wait_condition", + "change_train_wait_condition_data", "clean_cursor_stack", "clear_blueprint", "clear_selected_blueprint", + "clear_selected_deconstruction_item", "connect_rolling_stock", "copy_entity_settings", "craft", + "craft_blueprint_record", "create_blueprint_like", "cursor_split", "cursor_transfer", "custom_input", + "cycle_blueprint_book_backwards", "cycle_blueprint_book_forwards", "deconstruct", "delete_blueprint_record", + "delete_custom_tag", "delete_permission_group", "disconnect_rolling_stock", "drop_blueprint_record", + "drop_item", "drop_to_blueprint_book", "edit_custom_tag", "edit_permission_group", "edit_train_schedule", + "export_blueprint", "fast_entity_split", "fast_entity_transfer", "grab_blueprint_record", "gui_checked_state_changed", + "gui_click", "gui_elem_selected", "gui_selection_state_changed", "gui_text_changed", "import_blueprint", + "import_blueprint_string", "inventory_split", "inventory_transfer", "launch_rocket", "market_offer", + "mod_settings_changed", "open_achievements_gui", "open_blueprint_library_gui", "open_blueprint_record", + "open_bonus_gui", "open_character_gui", "open_equipment", "open_gui", "open_item", "open_kills_gui", + "open_logistic_gui", "open_production_gui", "open_technology_gui", "open_train_gui", "open_train_station_gui", + "open_trains_gui", "open_tutorials_gui", "paste_entity_settings", "place_equipment", "remove_cables", + "reset_assembling_machine", "reverse_rotate_entity", "rotate_entity", "select_area", "select_blueprint_entities", + "select_entity_slot", "select_gun", "select_item", "select_tile_slot", "set_auto_launch_rocket", "set_autosort_inventory", + "set_behavior_mode", "set_blueprint_icon", "set_circuit_condition", "set_circuit_mode_of_operation", + "set_deconstruction_item_tile_selection_mode", "set_deconstruction_item_trees_only", "set_entity_color", + "set_entity_energy_property", "set_filter", "set_inserter_max_stack_size", "set_inventory_bar", "set_logistic_filter_item", + "set_logistic_filter_signal", "set_logistic_trash_filter_item", "set_research_finished_stops_game", "set_signal", + "set_single_blueprint_record_icon", "set_train_stopped", "set_use_item_groups", "setup_assembling_machine", + "setup_blueprint", "setup_single_blueprint_record", "shortcut_quick_bar_transfer", "smart_pipette", "stack_split", + "stack_transfer", "start_repair", "start_research", "start_walking", "switch_connect_to_logistic_network", + "switch_constant_combinator_state", "switch_power_switch_state", "switch_to_rename_stop_gui", "take_equipment", + "toggle_connect_center_back_tank", "toggle_connect_front_center_tank", "toggle_deconstruction_item_entity_filter_mode", + "toggle_deconstruction_item_tile_filter_mode", "toggle_driving", "toggle_enable_vehicle_logistics_while_moving", + "toggle_entity_on_off_state", "toggle_show_entity_info", "use_ability", "use_item", "wire_dragging", "write_to_console", + }, + }, + inventory = { + fields = { + "assembling_machine_input", "assembling_machine_modules", "assembling_machine_output", "beacon_modules", + "burnt_result", "car_ammo", "car_trunk", "cargo_wagon", "chest", "fuel", "furnace_modules", + "furnace_result", "furnace_source", "god_main", "god_quickbar", "item_main", "lab_input", "lab_modules", + "mining_drill_modules", "player_ammo", "player_armor", "player_guns", "player_main", "player_quickbar", + "player_tools", "player_trash", "player_vehicle", "roboport_material", "roboport_robot", "rocket_silo_result", + "rocket_silo_rocket", "turret_ammo", "rocket", "character_corpse" + }, + }, + logistic_member_index = { + fields = { + "character_provider", "character_requester", "character_storage", "generic_on_off_behavior", "logistic_container", "vehicle_storage", + }, + }, + logistic_mode = { + fields = { + "active_provider", "none", "passive_provider", "requester", "storage", "buffer" + }, + }, + mouse_button_type = { + fields = { + "left", "middle", "none", "right", + }, + }, + rail_connection_direction = { + fields = { + "left", "none", "right", "straight", + }, + }, + rail_direction = { + fields = { + "back", "front", + }, + }, + riding = { + fields = { + acceleration = { + fields = { + "accelerating", "braking", "nothing", "reversing", + }, + }, + direction = { + fields = { + "left", "right", "straight", + } + }, + }, + }, + shooting = { + fields = { + "not_shooting", "shooting_enemies", "shooting_selected", + }, + }, + signal_state = { + fields = { + "closed", "open", "reserved", "reserved_by_circuit_network", + }, + }, + train_state = { + fields = { + "arrive_signal", "arrive_station", "manual_control", "manual_control_stop", "no_path", "no_schedule", + "on_the_path", "path_lost", "stop_for_auto_control", "wait_signal", "wait_station", + }, + }, + transport_line = { + fields = { + "left_line", "left_split_line", "left_underground_line", "right_line", "right_split_line", "right_underground_line", + "secondary_left_line", "secondary_left_split_line", "secondary_right_line", "secondary_right_split_line", + }, + }, + wire_type = { + fields = { + "copper", "green", "red", + } + }, + -- Deprecated + colors = { + other_fields = true, + }, + -- Deprecated + anticolors = { + other_fields = true, + }, + -- Deprecated + lightcolors = { + other_fields = true, + }, + color = { + other_fields = true, + }, + anticolor = { + other_fields = true, + }, + lightcolor = { + other_fields = true, + }, + time = { + fields = { + "second", "minute", "hour", "day", "week", "month", "year", + } + }, + }, + } + } +} --)) + +--[[ + "ignore", "std", "globals", "unused_args", "self", "compat", "global", "unused", "redefined", + "unused_secondaries", "allow_defined", "allow_defined_top", "module", + "read_globals", "new_globals", "new_read_globals", "enable", "only", "not_globals", + "max_line_length", "max_code_line_length", "max_string_line_length", "max_comment_line_length", + "max_cyclomatic_complexity" +--]] + +-- Warnings list +-- 011 A syntax error. +-- 021 An invalid inline option. +-- 022 An unpaired inline push directive. +-- 023 An unpaired inline pop directive. +-- 111 Setting an undefined global variable. +-- 112 Mutating an undefined global variable. +-- 113 Accessing an undefined global variable. +-- 121 Setting a read-only global variable. +-- 122 Setting a read-only field of a global variable. +-- 131 Unused implicitly defined global variable. +-- 142 Setting an undefined field of a global variable. +-- 143 Accessing an undefined field of a global variable. +-- 211 Unused local variable. +-- 212 Unused argument. +-- 213 Unused loop variable. +-- 221 Local variable is accessed but never set. +-- 231 Local variable is set but never accessed. +-- 232 An argument is set but never accessed. +-- 233 Loop variable is set but never accessed. +-- 241 Local variable is mutated but never accessed. +-- 311 Value assigned to a local variable is unused. +-- 312 Value of an argument is unused. +-- 313 Value of a loop variable is unused. +-- 314 Value of a field in a table literal is unused. +-- 321 Accessing uninitialized local variable. +-- 331 Value assigned to a local variable is mutated but never accessed. +-- 341 Mutating uninitialized local variable. +-- 411 Redefining a local variable. +-- 412 Redefining an argument. +-- 413 Redefining a loop variable. +-- 421 Shadowing a local variable. +-- 422 Shadowing an argument. +-- 423 Shadowing a loop variable. +-- 431 Shadowing an upvalue. +-- 432 Shadowing an upvalue argument. +-- 433 Shadowing an upvalue loop variable. +-- 511 Unreachable code. +-- 512 Loop can be executed at most once. +-- 521 Unused label. +-- 531 Left-hand side of an assignment is too short. +-- 532 Left-hand side of an assignment is too long. +-- 541 An empty do end block. +-- 542 An empty if branch. +-- 551 An empty statement. +-- 611 A line consists of nothing but whitespace. +-- 612 A line contains trailing whitespace. +-- 613 Trailing whitespace in a string. +-- 614 Trailing whitespace in a comment. +-- 621 Inconsistent indentation (SPACE followed by TAB). +-- 631 Line is too long. diff --git a/config/command_parse_roles.lua b/config/command_parse_roles.lua index 8f91863f..efdf2a00 100644 --- a/config/command_parse_roles.lua +++ b/config/command_parse_roles.lua @@ -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 diff --git a/config/roles.lua b/config/roles.lua index 8faf42e9..3069af98 100644 --- a/config/roles.lua +++ b/config/roles.lua @@ -91,7 +91,7 @@ Roles.new_role('Trainee','TrMod') 'command/goto', 'command/temp-ban', 'command/give-warning', - 'command/get-warning', + 'command/get-warnings', 'command/get-reports', } @@ -120,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') diff --git a/expcore/common.lua b/expcore/common.lua index 2390c5ef..481fc4b1 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -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 diff --git a/expcore/roles.lua b/expcore/roles.lua index f503798d..11df21dc 100644 --- a/expcore/roles.lua +++ b/expcore/roles.lua @@ -641,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 @@ -673,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 diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg index 07441927..2f205308 100644 --- a/locale/en/addons.cfg +++ b/locale/en/addons.cfg @@ -35,4 +35,5 @@ 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__) \ No newline at end of file +script-wrning-removed=A script warning has expired (__1__/__2__) +script-warning-limit=__1__ has recived a permiment warning from the script. \ No newline at end of file diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua index 7e4aa526..512c7724 100644 --- a/modules/addons/jail-control.lua +++ b/modules/addons/jail-control.lua @@ -38,7 +38,7 @@ 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 = Role.get_player_roles(player) + 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) diff --git a/modules/addons/reports-control.lua b/modules/addons/reports-control.lua index eacb212b..e71b97f5 100644 --- a/modules/addons/reports-control.lua +++ b/modules/addons/reports-control.lua @@ -57,6 +57,9 @@ function Public.remove_player_report(player,by_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 @@ -115,7 +118,11 @@ function Public.count_player_reports(player,count_callback) if not player then return end local reports = Public.user_reports[player.name] or {} if not count_callback then - return #reports + 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 diff --git a/modules/addons/warnings-control.lua b/modules/addons/warnings-control.lua index 18e12d19..d3c07bcd 100644 --- a/modules/addons/warnings-control.lua +++ b/modules/addons/warnings-control.lua @@ -2,6 +2,7 @@ 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 = { @@ -195,8 +196,8 @@ Event.add(Public.player_warning_added,function(event) elseif type(action) == 'table' then -- {locale,by_player_name,number_of_warning,...} local current_action = table.deep_copy(action) - table.insert(current_action,1,event.by_player_name) - table.insert(current_action,1,event.warning_count) + 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) @@ -208,6 +209,8 @@ 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 diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua index d6452252..6a30789f 100644 --- a/modules/commands/jail.lua +++ b/modules/commands/jail.lua @@ -48,13 +48,12 @@ 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_param('reason',false) :add_alias('untemp-ban','remove-temp-ban') :enable_auto_concat() -:register(function(player,action_player,reason,raw) +: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,reason) then + 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} diff --git a/modules/commands/reports.lua b/modules/commands/reports.lua index a1b83e45..3c57f533 100644 --- a/modules/commands/reports.lua +++ b/modules/commands/reports.lua @@ -8,7 +8,7 @@ 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(player,'report-immune') then + if Roles.player_has_flag(input,'report-immune') then return reject{'exp-commands.report-player-immune'} else return input @@ -45,7 +45,8 @@ Commands.new_command('get-reports','Gets a list of all reports that a player has 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) - Commands.print{'exp-commands.report-list',player_name_color,#reports} + local report_count = ReportsControl.count_player_reports(player_name) + Commands.print{'exp-commands.report-list',player_name_color,report_count} end end end) @@ -55,7 +56,7 @@ Commands.new_command('clear-reports','Clears all reports from a player or just t :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) then + if not ReportsControl.remove_player_report(action_player,from_player.name) then return Commands.error{'exp-commands.report-not-reported'} end else diff --git a/modules/commands/warnings.lua b/modules/commands/warnings.lua index e4b0cb2c..ae3c9692 100644 --- a/modules/commands/warnings.lua +++ b/modules/commands/warnings.lua @@ -49,8 +49,8 @@ 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(player,player.name) - WarningsControl.clear_temp_warnings(player,player.name) + 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} From c98ed90cdaf54db5991046997e6b6ed7ab19ce34 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 19 Apr 2019 14:08:16 +0100 Subject: [PATCH 18/18] Ingrone luacheck --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 697e15f8..9a140dc8 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,5 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -*.vscode \ No newline at end of file +.vscode +*luacheckrc