From 326618df180a72f700f9917e1139f246abae918e Mon Sep 17 00:00:00 2001 From: Duncan Brown Date: Sun, 6 Feb 2022 05:24:55 -0500 Subject: [PATCH] fix: set a proper guard in case of no speaking animations (#488) + correct the upper limit check for the speaking index Co-authored-by: Duncan Brown --- addons/escoria-core/game/core-scripts/esc_item.gd | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/escoria-core/game/core-scripts/esc_item.gd b/addons/escoria-core/game/core-scripts/esc_item.gd index e3f3f3ed1..65b723478 100644 --- a/addons/escoria-core/game/core-scripts/esc_item.gd +++ b/addons/escoria-core/game/core-scripts/esc_item.gd @@ -452,9 +452,11 @@ func turn_to(object: Node, wait: float = 0.0): # Play the talking animation func start_talking(): - if get_animation_player() and \ - _movable.last_dir >= 0 and \ - _movable.last_dir <= animations.speaks.size(): + # Only start the speaking animation if we actually have them setup + if animations.speaks.size() > 0 \ + and get_animation_player() \ + and _movable.last_dir >= 0 \ + and _movable.last_dir < animations.speaks.size(): if get_animation_player().is_playing(): get_animation_player().stop() get_animation_player().play( @@ -464,9 +466,10 @@ func start_talking(): # Stop playing the talking animation func stop_talking(): - if get_animation_player() and \ - _movable.last_dir >= 0 and \ - _movable.last_dir <= animations.idles.size(): + if animations.speaks.size() > 0 \ + and get_animation_player() \ + and _movable.last_dir >= 0 \ + and _movable.last_dir < animations.speaks.size(): if get_animation_player().is_playing(): get_animation_player().stop() get_animation_player().play(