Skip to content

Commit

Permalink
fix: set a proper guard in case of no speaking animations (#488)
Browse files Browse the repository at this point in the history
+ correct the upper limit check for the speaking index
Co-authored-by: Duncan Brown <[email protected]>
  • Loading branch information
BHSDuncan authored Feb 6, 2022
1 parent 6f346a9 commit 326618d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions addons/escoria-core/game/core-scripts/esc_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 326618d

Please sign in to comment.