Fix: find_nearest_nonzero() NoneType error

This commit is contained in:
Gleed
2022-06-20 18:28:01 -04:00
committed by GitHub
parent dc75cce5dc
commit 5597df55ca
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -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)
+3
View File
@@ -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)