diff --git a/addons/escoria-core/game/core-scripts/esc_game.gd b/addons/escoria-core/game/core-scripts/esc_game.gd index 0481cafa..ede89827 100644 --- a/addons/escoria-core/game/core-scripts/esc_game.gd +++ b/addons/escoria-core/game/core-scripts/esc_game.gd @@ -162,11 +162,17 @@ func do_walk(destination, params: Array = [], can_interrupt: bool = false) -> vo # # - position: Position clicked func left_click_on_bg(position: Vector2) -> void: - do_walk( - position, - [escoria.main.current_scene.player.global_id], - true - ) + if escoria.main.current_scene.player: + do_walk( + position, + [escoria.main.current_scene.player.global_id], + true + ) + else: + escoria.logger.trace( + self, + "No player loaded for current scene. Ignoring left click on background." + ) # Called when the player right clicks on the background @@ -176,11 +182,17 @@ func left_click_on_bg(position: Vector2) -> void: # # - position: Position clicked func right_click_on_bg(position: Vector2) -> void: - do_walk( - position, - [escoria.main.current_scene.player.global_id], - true - ) + if escoria.main.current_scene.player: + do_walk( + position, + [escoria.main.current_scene.player.global_id], + true + ) + else: + escoria.logger.trace( + self, + "No player loaded for current scene. Ignoring right click on background." + ) # Called when the player double clicks on the background @@ -190,11 +202,18 @@ func right_click_on_bg(position: Vector2) -> void: # # - position: Position clicked func left_double_click_on_bg(position: Vector2) -> void: - do_walk( - position, - [escoria.main.current_scene.player.global_id, true], - true - ) + if escoria.main.current_scene.player: + do_walk( + position, + [escoria.main.current_scene.player.global_id, true], + true + ) + else: + escoria.logger.trace( + self, + "No player loaded for current scene. Ignoring left double-click on background." + ) + # Called when an element in the scene was focused # (Needs to be overridden, if supported)