fix: guards against scenes with no player set or loaded
This commit is contained in:
@@ -162,11 +162,17 @@ func do_walk(destination, params: Array = [], can_interrupt: bool = false) -> vo
|
|||||||
#
|
#
|
||||||
# - position: Position clicked
|
# - position: Position clicked
|
||||||
func left_click_on_bg(position: Vector2) -> void:
|
func left_click_on_bg(position: Vector2) -> void:
|
||||||
do_walk(
|
if escoria.main.current_scene.player:
|
||||||
position,
|
do_walk(
|
||||||
[escoria.main.current_scene.player.global_id],
|
position,
|
||||||
true
|
[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
|
# Called when the player right clicks on the background
|
||||||
@@ -176,11 +182,17 @@ func left_click_on_bg(position: Vector2) -> void:
|
|||||||
#
|
#
|
||||||
# - position: Position clicked
|
# - position: Position clicked
|
||||||
func right_click_on_bg(position: Vector2) -> void:
|
func right_click_on_bg(position: Vector2) -> void:
|
||||||
do_walk(
|
if escoria.main.current_scene.player:
|
||||||
position,
|
do_walk(
|
||||||
[escoria.main.current_scene.player.global_id],
|
position,
|
||||||
true
|
[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
|
# Called when the player double clicks on the background
|
||||||
@@ -190,11 +202,18 @@ func right_click_on_bg(position: Vector2) -> void:
|
|||||||
#
|
#
|
||||||
# - position: Position clicked
|
# - position: Position clicked
|
||||||
func left_double_click_on_bg(position: Vector2) -> void:
|
func left_double_click_on_bg(position: Vector2) -> void:
|
||||||
do_walk(
|
if escoria.main.current_scene.player:
|
||||||
position,
|
do_walk(
|
||||||
[escoria.main.current_scene.player.global_id, true],
|
position,
|
||||||
true
|
[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
|
# Called when an element in the scene was focused
|
||||||
# (Needs to be overridden, if supported)
|
# (Needs to be overridden, if supported)
|
||||||
|
|||||||
Reference in New Issue
Block a user