Merge branch 'hotfix/5.3.2' into dev

This commit is contained in:
Cooldude2606
2019-04-15 23:11:12 +01:00
7 changed files with 82 additions and 12 deletions

View File

@@ -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',
@@ -23,6 +24,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

View File

@@ -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)
@@ -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

View File

@@ -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 <any> 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,'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)
end
command_log(player,command_data,'Success',raw_params,input_string)

View File

@@ -18,6 +18,8 @@
local Colours = require 'resources.color_presets'
local Game = require 'utils.game'
local Util = require 'util'
require 'utils.table'
require 'utils.math'
local Public = {}
@@ -96,7 +98,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
@@ -495,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

View File

@@ -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
@@ -222,7 +223,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

View File

@@ -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__
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]

View File

@@ -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 '<Server>'
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)