Skip to content

Commit ececccc

Browse files
authored
add null check to text update_name_label (#1506)
There are a few places where we do a `update_name_label(null)`, which makes `character.resource_path` throw an invalid index error. This commit fixes this bug; also a fixes a related bug in the same function where it is possible to access `dialogic.current_state_info['character']` before it is defined.
1 parent 9902e0a commit ececccc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

addons/dialogic/Events/Text/subsystem_text.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ func _on_dialog_text_finished():
8787

8888

8989
func update_name_label(character:DialogicCharacter) -> void:
90-
if character.resource_path == dialogic.current_state_info['character']:
90+
var character_path = character.resource_path if character else null
91+
if character_path == dialogic.current_state_info.get('character'):
9192
return
9293
for name_label in get_tree().get_nodes_in_group('dialogic_name_label'):
9394
if character:
94-
dialogic.current_state_info['character'] = character.resource_path
95+
dialogic.current_state_info['character'] = character_path
9596
if dialogic.has_subsystem('VAR'):
9697
name_label.text = dialogic.VAR.parse_variables(character.display_name)
9798
else:

0 commit comments

Comments
 (0)