From 40fc85bb7cc7efd2d5bccc94b2a3e2e59c29f90a Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 21:02:59 +0100 Subject: [PATCH 1/7] gitflow-hotfix-stash: 5.3.2 --- config/file_loader.lua | 1 + config/roles.lua | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/file_loader.lua b/config/file_loader.lua index 3cbd4fac..7eea99d0 100644 --- a/config/file_loader.lua +++ b/config/file_loader.lua @@ -23,6 +23,7 @@ return { 'modules.addons.spawn-area', 'modules.addons.compilatron', 'modules.addons.scorched-earth', + 'modules.addons.pollution-grading', -- 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/config/roles.lua b/config/roles.lua index 29c0017b..2b2fc6ac 100644 --- a/config/roles.lua +++ b/config/roles.lua @@ -120,7 +120,7 @@ Roles.new_role('Veteran','Vet') :allow{ } :set_auto_promote_condition(function(player) - if player.online_time > 10*hours then + if player.online_time > 10*216000 then return true end end) @@ -141,7 +141,7 @@ Roles.new_role('Regular','Reg') 'command/kill' } :set_auto_promote_condition(function(player) - if player.online_time > 3*hours then + if player.online_time > 3*216000 then return true end end) From 4e643954be0370720081a5cc72f5671a15befff7 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 21:18:09 +0100 Subject: [PATCH 2/7] Fixed Color Tags --- expcore/roles.lua | 2 +- locale/en/commands.cfg | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/expcore/roles.lua b/expcore/roles.lua index 09fc11e0..215d0885 100644 --- a/expcore/roles.lua +++ b/expcore/roles.lua @@ -222,7 +222,7 @@ function Roles.debug() local role = Roles.config.roles[role_name] local color = role.custom_color or Colours.white color = string.format('[color=%d,%d,%d]',color.r,color.g,color.b) - output = output..string.format('\n%s %s) %s',color,index,serpent.line(role)) + output = output..string.format('\n%s %s) %s[/color]',color,index,serpent.line(role)) end return output end diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 54e3a84a..393aae20 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__: __2__ +admin-chat-format=[Admin Chat] [color=__3__]__1__[/color]: __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,6 @@ 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__ -roles-list-player=[color=__1__]__2__ has: [color=__3__]__4__ -roles-list-element=__1__, [color=__2__]__3__ \ No newline at end of file +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 From 549a7ebff53363c733cd28a9d7b45a2f9f847645 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 21:45:20 +0100 Subject: [PATCH 3/7] fixed player_return desync --- expcore/common.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/expcore/common.lua b/expcore/common.lua index 145e19d8..538fa894 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -18,6 +18,7 @@ local Colours = require 'resources.color_presets' local Game = require 'utils.game' local Util = require 'util' +require 'utils.table' local Public = {} @@ -96,7 +97,7 @@ function Public.player_return(value,colour,player) returnAsString = tostring(value) else -- value is a table - returnAsString = serpent.block(value) + returnAsString = table.inspect(value,{depth=5,indent=' ',newline='\n'}) end elseif Public.type_check(value,'function') then -- value is a function From 4fd9b2e1a122dd76904552df8f230d7fd6247462 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 21:53:57 +0100 Subject: [PATCH 4/7] Fixed Role Change Logging --- expcore/roles.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/expcore/roles.lua b/expcore/roles.lua index 215d0885..6cf5b71b 100644 --- a/expcore/roles.lua +++ b/expcore/roles.lua @@ -180,9 +180,10 @@ local function emit_player_roles_updated(player,type,roles,by_player_name) local by_player = Game.get_player_from_any(by_player_name) local by_player_index = by_player and by_player.index or 0 local role_names = {} - for _,role in pairs(roles) do + for index,role in pairs(roles) do role = Roles.get_role_from_any(role) if role then + roles[index] = role table.insert(role_names,role.name) end end @@ -198,7 +199,7 @@ local function emit_player_roles_updated(player,type,roles,by_player_name) player_name=player.name, by_player_name=by_player_name, type=type, - roles_changed=roles + roles_changed=role_names }..'\n',true,0) end From 4778b057d8a8b5c8642f69a128771af3b5f7554c Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 21:58:29 +0100 Subject: [PATCH 5/7] Fixed no Error in command log --- expcore/commands.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/expcore/commands.lua b/expcore/commands.lua index b9eb5186..806efa56 100644 --- a/expcore/commands.lua +++ b/expcore/commands.lua @@ -162,6 +162,7 @@ return Commands.error(message[opt]) -- this returns an error to the user, and will halt the command execution, ie no success message is returned Commands.success(message[opt]) -- used to return a success message however dont use this method see below return Commands.success(message[opt]) -- will return the success message to the user and your given message, halts execution + return if any value is returned then it will be returned to the player via a Commands.success call Example Code: Commands.new_command('repeat-name','Will repeat you name a number of times in chat.') @@ -728,7 +729,10 @@ function Commands.run_command(command_event) 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) end - if err ~= Commands.defines.error and err ~= Commands.defines.success and err ~= Commands.error and err ~= Commands.success then + if err == Commands.defines.error or err == Commands.error then + return command_log(player,command_data,'Error',raw_params,input_string) + elseif err ~= Commands.defines.success and err ~= Commands.success then + -- in this case the user has not received any output Commands.success(err) end command_log(player,command_data,'Success',raw_params,input_string) From 1bcb407faad018d1ffc5adebd82c065ad5fadb13 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 21:59:19 +0100 Subject: [PATCH 6/7] Canged Error to Custom Error for comamnd log --- expcore/commands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expcore/commands.lua b/expcore/commands.lua index 806efa56..9a8ef7f9 100644 --- a/expcore/commands.lua +++ b/expcore/commands.lua @@ -730,7 +730,7 @@ function Commands.run_command(command_event) return command_log(player,command_data,'Internal Error: Command Callback Fail',params,command_event.parameter,err) end if err == Commands.defines.error or err == Commands.error then - return command_log(player,command_data,'Error',raw_params,input_string) + return command_log(player,command_data,'Custom Error',raw_params,input_string) elseif err ~= Commands.defines.success and err ~= Commands.success then -- in this case the user has not received any output Commands.success(err) From 361513c6572455d0e4dc9299e06e6db4859e0b8c Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Mon, 15 Apr 2019 22:59:31 +0100 Subject: [PATCH 7/7] Added /rainbow --- config/file_loader.lua | 1 + config/roles.lua | 3 +- expcore/common.lua | 7 +++++ modules/commands/rainbow.lua | 54 ++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 modules/commands/rainbow.lua diff --git a/config/file_loader.lua b/config/file_loader.lua index 7eea99d0..7a85b3cc 100644 --- a/config/file_loader.lua +++ b/config/file_loader.lua @@ -15,6 +15,7 @@ return { 'modules.commands.interface', 'modules.commands.help', 'modules.commands.roles', + 'modules.commands.rainbow', -- QoL Addons 'modules.addons.chat-popups', 'modules.addons.damage-popups', diff --git a/config/roles.lua b/config/roles.lua index 2b2fc6ac..2e239c19 100644 --- a/config/roles.lua +++ b/config/roles.lua @@ -155,7 +155,8 @@ Roles.new_role('Guest','') 'command/tag', 'command/tag-clear', 'command/chelp', - 'command/list-roles' + 'command/list-roles', + 'command/rainbow' } --- Jail role diff --git a/expcore/common.lua b/expcore/common.lua index 538fa894..4c3478fa 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -19,6 +19,7 @@ local Colours = require 'resources.color_presets' local Game = require 'utils.game' local Util = require 'util' require 'utils.table' +require 'utils.math' local Public = {} @@ -496,4 +497,10 @@ function Public.table_keysort(tbl) return _tbl end +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 + return Public \ No newline at end of file diff --git a/modules/commands/rainbow.lua b/modules/commands/rainbow.lua new file mode 100644 index 00000000..f2d03cda --- /dev/null +++ b/modules/commands/rainbow.lua @@ -0,0 +1,54 @@ +local Commands = require 'expcore.commands' +local format_chat_colour = ext_require('expcore.common','format_chat_colour') + +local function step_component(c1,c2) + if c1 < 0 then + return 0,c2+c1 + elseif c1 > 1 then + return 1,c2-c1+1 + else + return c1,c2 + end +end + +local function step_color(color) + color.r,color.g = step_component(color.r,color.g) + color.g,color.b = step_component(color.g,color.b) + color.b,color.r = step_component(color.b,color.r) + color.r = step_component(color.r,0) + return color +end + +local function next_color(color,step) + step = step or 0.1 + local new_color = {r=0,g=0,b=0} + if color.b == 0 and color.r ~= 0 then + new_color.r = color.r-step + new_color.g = color.g+step + elseif color.r == 0 and color.g ~= 0 then + new_color.g = color.g-step + new_color.b = color.b+step + elseif color.g == 0 and color.b ~= 0 then + new_color.b = color.b-step + new_color.r = color.r+step + end + return step_color(new_color) +end + +Commands.new_command('rainbow','Sends an rainbow message in the chat') +:add_param('message',false) -- action that is done by the player, just text its meaningless +:enable_auto_concat() +:register(function(player,message,raw) + local player_name = player and player.name or '' + local player_color = player and player.color or nil + local color_step = 3/message:len() + if color_step > 1 then color_step = 1 end + local current_color = {r=1,g=0,b=0} + local output = format_chat_colour(player_name..': ',player_color) + output = output..message:gsub('%S',function(letter) + local rtn = format_chat_colour(letter,current_color) + current_color = next_color(current_color,color_step) + return rtn + end) + game.print(output) +end) \ No newline at end of file