You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Error: Invalid get index 'char_name' (on base: 'Dictionary'). res://addons/dialogue_manager/utilities/builtins.gd:29 - at function:resolve_property
char_name is a key of the dictionary I'm trying to access Affected version
Dialogue Manager version: v2.39.0
Godot version: 4.2.1.stable
To Reproduce
Steps to reproduce the behavior: Trying to access to a variable on a dictionary updated on runtime, on ready
I have an autoloaded script in the dialogue manager called dialogue_state in which I'm trying to store a dictionary with all the variables of every character in the scene. var char_dict = {}
Then, I have a class character, that on ready it stores itself on the dictionary of dialogue_state, it is done this way to store only dynamically the characters on this scene.
class_name character
@onready var dialogue_state = %"Dialogue state"
#Dialogue stats
@export var character_name : String
var times_talked : int = 0
func _ready():
dialogue_state.char_dict[character_name] = self
pass
And in the dialogue, I try to access the dictionary variables.
~ start
if char_dict.char_name.times_talked == 0:
Name: Hello
So when I try to access a variable on the dictionary I get this error
Expected behavior
To be able to access times_talked of the desired character.
I'm able to access them from the script dialogue_state even if I can't from the dialogue manager
func _on_timer_timeout():
print_dict()
func print_dict():
for i in char_dict:
print(char_dict[i].character_name)
print(char_dict.char_name.times_talked)
But if I define the class in the definition of the dictionary instead of in the character, it works as it should be.
var char_dict = {"char_name": character.new()}
Thank you for your time.
The text was updated successfully, but these errors were encountered:
You have two copies of your game state - an autoload (the correct one) and one in the local scene (the one you are accidentally editing in that example). You should remove the state node in the scene and then in your _ready function, update the global state instead.
Describe the bug
Error:
Invalid get index 'char_name' (on base: 'Dictionary').
res://addons/dialogue_manager/utilities/builtins.gd:29 - at function:resolve_property
char_name
is a key of the dictionary I'm trying to accessAffected version
To Reproduce
Steps to reproduce the behavior: Trying to access to a variable on a dictionary updated on runtime, on ready
I have an autoloaded script in the dialogue manager called
dialogue_state
in which I'm trying to store a dictionary with all the variables of every character in the scene.var char_dict = {}
Then, I have a class
character
, that on ready it stores itself on the dictionary ofdialogue_state
, it is done this way to store only dynamically the characters on this scene.And in the dialogue, I try to access the dictionary variables.
So when I try to access a variable on the dictionary I get this error
Expected behavior
To be able to access
times_talked
of the desired character.I'm able to access them from the script
dialogue_state
even if I can't from the dialogue managerBut if I define the class in the definition of the dictionary instead of in the character, it works as it should be.
var char_dict = {"char_name": character.new()}
Thank you for your time.
The text was updated successfully, but these errors were encountered: