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