From 779adff2122f914034a683efb5152b3503c5847c Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Thu, 6 Jun 2024 03:33:56 +0900 Subject: [PATCH] Make commands display in game chat (#297) * Update friendly-fire.lua * Update research.lua * Update friendly-fire.lua * Update speed.lua * Update cheat-mode.lua * Update bot-queue.lua * Update train.lua * Update pollution.lua * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update cheat-mode.lua * Update research.lua * Update commands.cfg * Update commands.cfg * Update commands.cfg --- locale/en/commands.cfg | 17 +++++++++-------- locale/zh-CN/commands.cfg | 17 +++++++++-------- locale/zh-TW/commands.cfg | 17 +++++++++-------- modules/commands/bot-queue.lua | 3 ++- modules/commands/cheat-mode.lua | 8 +++++--- modules/commands/friendly-fire.lua | 5 +++-- modules/commands/pollution.lua | 6 ++++-- modules/commands/research.lua | 3 ++- modules/commands/speed.lua | 5 +++-- modules/commands/train.lua | 3 ++- 10 files changed, 48 insertions(+), 36 deletions(-) diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 19834254..6f859e60 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -113,26 +113,27 @@ results-item=__1__) __2__ has __3__ items. (__4__) results-none=No players have [item=__1__] [expcom-speed] -result=The game speed is now __1__ +result=__1__ set the game speed to __2__ [expcom-bot-queue] -result=The successful attempts are currently __1__ and failed attempts are __2__. +result=__1__ set the bot queue to __1__ successful attempts and __2__ failed attempts [expcom-pol] -clr=The server had pollution **REMOVED** by __1__. Please @staff on the discord if this was done by mistake. -off=The server had pollution **DISABLED** by __1__. Please @staff on the discord if this was done by mistake. +clr=__1__ removed the pollution. +off=__1__ disabled the pollution. [expcom-train] -manual-result=Set __1__ trains into automatic mode. +manual-result=__1__ put __2__ trains into automatic mode [expcom-cheat] -day=Always day is set to __1__ +res=__1__ has enabled all technologies +day=__1__ set always day to __2__ [expcom-ff] -ff=Friendly fire is set to __1__ +ff=__1__ set friendly fire to __2__ [expcom-res] -res=Auto Research is set to __1__ +res=__1__ set auto research to __2__ msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color] inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color] inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color] diff --git a/locale/zh-CN/commands.cfg b/locale/zh-CN/commands.cfg index 6386cf5f..d38eaa96 100644 --- a/locale/zh-CN/commands.cfg +++ b/locale/zh-CN/commands.cfg @@ -113,26 +113,27 @@ results-item=__1__) __2__ 有 __3__ 個. (__4__) results-none=沒用戶有 [item=__1__] [expcom-speed] -result=The game speed is now __1__ +result=__1__ set the game speed to __2__ [expcom-bot-queue] -result=The successful attempts are currently __1__ and failed attempts are __2__ +result=__1__ set the bot queue to __1__ successful attempts and __2__ failed attempts [expcom-pol] -clr=The server had pollution **REMOVED** by __1__. Please @staff on the discord if this was done by mistake. -off=The server had pollution **DISABLED** by __1__. Please @staff on the discord if this was done by mistake. +clr=__1__ removed the pollution. +off=__1__ disabled the pollution. [expcom-train] -manual-result=Set __1__ train into automatic mode. +manual-result=__1__ put __2__ trains into automatic mode [expcom-cheat] -day=Always day is set to __1__ +res=__1__ has enabled all technologies +day=__1__ set always day to __2__ [expcom-ff] -ff=Friendly fire is set to __1__ +ff=__1__ set friendly fire to __2__ [expcom-res] -res=Auto Research is set to __1__ +res=__1__ set auto research to __2__ msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color] inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color] inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color] diff --git a/locale/zh-TW/commands.cfg b/locale/zh-TW/commands.cfg index 6386cf5f..d38eaa96 100644 --- a/locale/zh-TW/commands.cfg +++ b/locale/zh-TW/commands.cfg @@ -113,26 +113,27 @@ results-item=__1__) __2__ 有 __3__ 個. (__4__) results-none=沒用戶有 [item=__1__] [expcom-speed] -result=The game speed is now __1__ +result=__1__ set the game speed to __2__ [expcom-bot-queue] -result=The successful attempts are currently __1__ and failed attempts are __2__ +result=__1__ set the bot queue to __1__ successful attempts and __2__ failed attempts [expcom-pol] -clr=The server had pollution **REMOVED** by __1__. Please @staff on the discord if this was done by mistake. -off=The server had pollution **DISABLED** by __1__. Please @staff on the discord if this was done by mistake. +clr=__1__ removed the pollution. +off=__1__ disabled the pollution. [expcom-train] -manual-result=Set __1__ train into automatic mode. +manual-result=__1__ put __2__ trains into automatic mode [expcom-cheat] -day=Always day is set to __1__ +res=__1__ has enabled all technologies +day=__1__ set always day to __2__ [expcom-ff] -ff=Friendly fire is set to __1__ +ff=__1__ set friendly fire to __2__ [expcom-res] -res=Auto Research is set to __1__ +res=__1__ set auto research to __2__ msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color] inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color] inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color] diff --git a/modules/commands/bot-queue.lua b/modules/commands/bot-queue.lua index 45abfc68..4d165ee8 100644 --- a/modules/commands/bot-queue.lua +++ b/modules/commands/bot-queue.lua @@ -20,5 +20,6 @@ Commands.new_command('bot-queue-set', 'Set bot queue') :register(function(player, amount) player.force.max_successful_attempts_per_tick_per_construction_queue = 3 * amount player.force.max_failed_attempts_per_tick_per_construction_queue = 1 * amount - return Commands.success{'expcom-bot-queue.result', 3 * amount, 1 * amount} + game.print{'expcom-bot-queue.result', player.name, 3 * amount, 1 * amount} + return Commands.success end) diff --git a/modules/commands/cheat-mode.lua b/modules/commands/cheat-mode.lua index 1f2ada17..b4fe93f7 100644 --- a/modules/commands/cheat-mode.lua +++ b/modules/commands/cheat-mode.lua @@ -26,8 +26,9 @@ Commands.new_command('research-all', 'Set all research for your force.') :set_defaults{force=function(player) return player.force end} -:register(function(_, force) +:register(function(player, force) force.research_all_technologies() + game.print{'expcom-cheat.res', player.name} return Commands.success end) @@ -37,7 +38,8 @@ Commands.new_command('toggle-always-day', 'Toggles always day in surface') :set_defaults{surface=function(player) return player.surface end} -:register(function(_, surface) +:register(function(player, surface) surface.always_day = not surface.always_day - return Commands.success{'expcom-cheat.day', surface.always_day} + game.print{'expcom-cheat.day', player.name, surface.always_day} + return Commands.success end) diff --git a/modules/commands/friendly-fire.lua b/modules/commands/friendly-fire.lua index 87db2c03..0f51000e 100644 --- a/modules/commands/friendly-fire.lua +++ b/modules/commands/friendly-fire.lua @@ -12,7 +12,8 @@ Commands.new_command('toggle-friendly-fire', 'Toggle Friendly Fire') :set_defaults{force=function(player) return player.force end} -:register(function(_, force) +:register(function(player, force) force.friendly_fire = not force.friendly_fire - return Commands.success{'expcom-ff.ff', force.friendly_fire} + game.print{'expcom-ff.ff', player.name, force.friendly_fire} + return Commands.success end) diff --git a/modules/commands/pollution.lua b/modules/commands/pollution.lua index 4927a8ff..be2d783f 100644 --- a/modules/commands/pollution.lua +++ b/modules/commands/pollution.lua @@ -15,7 +15,8 @@ Commands.new_command('pollution-clear', 'Clear pollution') end} :register(function(player, surface) surface.clear_pollution() - return Commands.success{'expcom-pol.clr', player.name} + game.print{'expcom-pol.clr', player.name} + return Commands.success end) Commands.new_command('pollution-off', 'Disable pollution') @@ -28,5 +29,6 @@ Commands.new_command('pollution-off', 'Disable pollution') v.clear_pollution() end - return Commands.success{'expcom-pol.off', player.name} + game.print{'expcom-pol.off', player.name} + return Commands.success end) diff --git a/modules/commands/research.lua b/modules/commands/research.lua index 0f8e039d..9b9a9712 100644 --- a/modules/commands/research.lua +++ b/modules/commands/research.lua @@ -103,5 +103,6 @@ Commands.new_command('auto-research', 'Automatically queue up research') res_queue(player.force) end - return game.print{'expcom-res.res', research.res_queue_enable} + game.print{'expcom-res.res', player.name, research.res_queue_enable} + return Commands.success end) diff --git a/modules/commands/speed.lua b/modules/commands/speed.lua index 0b5dbab8..f313ee27 100644 --- a/modules/commands/speed.lua +++ b/modules/commands/speed.lua @@ -9,7 +9,8 @@ require 'config.expcore.command_general_parse' Commands.new_command('game-speed', 'Set game speed') :add_param('amount', 'number-range', 0.2, 1) :set_flag('admin_only') -:register(function(_, amount) +:register(function(player, amount) game.speed = math.round(amount, 3) - return Commands.success{'expcom-speed.result', string.format('%.3f', amount)} + game.print{'expcom-speed.result', player.name, string.format('%.3f', amount)} + return Commands.success end) diff --git a/modules/commands/train.lua b/modules/commands/train.lua index 470bd76a..af440465 100644 --- a/modules/commands/train.lua +++ b/modules/commands/train.lua @@ -18,5 +18,6 @@ Commands.new_command('set-trains-to-automatic', 'Set All Trains to Automatic') end end - return Commands.success{'expcom-train.manual-result', format_number(count)} + game.print{'expcom-train.manual-result', player.name, format_number(count)} + return Commands.success end)