From 99c1e1d6dc4d4d649beda1c78a4bb32a0d65d22a Mon Sep 17 00:00:00 2001 From: NicEastvillage Date: Mon, 16 Nov 2026 22:12:48 +0100 Subject: [PATCH] Update set_game_state() API and add send_console_command() --- rlbot/interface.py | 1 + rlbot/managers/bot.py | 14 ++++++++++---- rlbot/managers/hivemind.py | 14 ++++++++++---- rlbot/managers/match.py | 14 ++++++++++---- rlbot/managers/script.py | 14 ++++++++++---- rlbot/version.py | 2 +- tests/atba/atba.py | 2 +- tests/many_match.py | 2 +- tests/run_forever.py | 2 +- 9 files changed, 45 insertions(+), 20 deletions(-) diff --git a/rlbot/interface.py b/rlbot/interface.py index 42fcc04..0ed4a9b 100644 --- a/rlbot/interface.py +++ b/rlbot/interface.py @@ -120,6 +120,7 @@ def send_msg( | flat.MatchConfiguration | flat.PlayerInput | flat.DesiredGameState + | flat.ConsoleCommand | flat.RenderGroup | flat.RemoveRenderGroup | flat.MatchComm diff --git a/rlbot/managers/bot.py b/rlbot/managers/bot.py index 935eb04..13d9f5f 100644 --- a/rlbot/managers/bot.py +++ b/rlbot/managers/bot.py @@ -274,20 +274,26 @@ def send_match_comm( ) ) - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self._game_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self._game_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self._game_interface.send_msg(game_state) def set_loadout(self, loadout: flat.PlayerLoadout, index: int | None = None): diff --git a/rlbot/managers/hivemind.py b/rlbot/managers/hivemind.py index 53ca25c..6b11b63 100644 --- a/rlbot/managers/hivemind.py +++ b/rlbot/managers/hivemind.py @@ -290,20 +290,26 @@ def send_match_comm( ) ) - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self._game_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self._game_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self._game_interface.send_msg(game_state) def set_loadout(self, loadout: flat.PlayerLoadout, index: int): diff --git a/rlbot/managers/match.py b/rlbot/managers/match.py index fd10978..0fa0a68 100644 --- a/rlbot/managers/match.py +++ b/rlbot/managers/match.py @@ -237,20 +237,26 @@ def stop_match(self): self.packet = None self.rlbot_interface.stop_match() - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self.rlbot_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self.rlbot_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self.rlbot_interface.send_msg(game_state) def shut_down(self, use_force_if_necessary: bool = True): diff --git a/rlbot/managers/script.py b/rlbot/managers/script.py index afb9944..ae4c925 100644 --- a/rlbot/managers/script.py +++ b/rlbot/managers/script.py @@ -234,20 +234,26 @@ def send_match_comm( ) ) - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self._game_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self._game_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self._game_interface.send_msg(game_state) def set_loadout(self, loadout: flat.PlayerLoadout, index: int): diff --git a/rlbot/version.py b/rlbot/version.py index fa3337d..6e93f11 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.56" +__version__ = "2.0.0-beta.57" diff --git a/tests/atba/atba.py b/tests/atba/atba.py index 4d5cc3c..6d94374 100644 --- a/tests/atba/atba.py +++ b/tests/atba/atba.py @@ -122,7 +122,7 @@ def get_output(self, packet: flat.GamePacket) -> flat.ControllerState: def test_state_setting(self, packet: flat.GamePacket): if packet.match_info.seconds_elapsed > self.next_teleport: self.next_teleport = packet.match_info.seconds_elapsed + 10 - self.set_game_state( + self.set_game_state_parts( { 0: flat.DesiredBallState( flat.DesiredPhysics( diff --git a/tests/many_match.py b/tests/many_match.py index 4942ada..a641549 100644 --- a/tests/many_match.py +++ b/tests/many_match.py @@ -80,7 +80,7 @@ def handle_match_comm(comm: flat.MatchComm): match_manager.packet.match_info.match_phase == flat.MatchPhase.Active and match_manager.packet.match_info.game_time_remaining < 60 * 4 + 55 ): - match_manager.set_game_state(commands=["Pause"]) + match_manager.send_console_command("Pause") paused = True break sleep(1) diff --git a/tests/run_forever.py b/tests/run_forever.py index 8efe3b1..f785c16 100644 --- a/tests/run_forever.py +++ b/tests/run_forever.py @@ -56,7 +56,7 @@ while match_manager.packet.match_info.match_phase != flat.MatchPhase.Ended: if match_manager.packet.match_info.match_phase == flat.MatchPhase.Countdown: - match_manager.set_game_state( + match_manager.set_game_state_parts( match_info=flat.DesiredMatchInfo(game_speed=2) )