From 5597df55cabe3abd8724da004235ec0ce12905ea Mon Sep 17 00:00:00 2001 From: Gleed Date: Mon, 20 Jun 2022 18:28:01 -0400 Subject: [PATCH] Fix: find_nearest_nonzero() NoneType error --- src/pather.py | 2 +- src/ui_manager.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pather.py b/src/pather.py index 87b9ba6..3615e67 100644 --- a/src/pather.py +++ b/src/pather.py @@ -630,7 +630,7 @@ class Pather: else: angle = random.random() * math.pi * 2 pos_abs = (math.cos(angle) * 150, math.sin(angle) * 150) - pos_abs = get_closest_non_hud_pixel(pos = node_pos_abs, pos_type="abs") + pos_abs = get_closest_non_hud_pixel(pos = pos_abs, pos_type="abs") Logger.debug(f"Pather: taking a random guess towards " + str(pos_abs)) x_m, y_m = convert_abs_to_monitor(pos_abs) char.move((x_m, y_m), force_move=True) diff --git a/src/ui_manager.py b/src/ui_manager.py index efceebd..450b029 100644 --- a/src/ui_manager.py +++ b/src/ui_manager.py @@ -371,6 +371,9 @@ def get_closest_non_hud_pixel(pos : tuple[int, int], pos_type: str = "abs") -> t :param pos: The target pixel :return: The closest non-hud pixel """ + if pos is None: + Logger.error(f"get_closest_non_hud_pixel: Received empty position!") + return (0,0) match pos_type: case "abs": pos = convert_abs_to_screen(pos)