Hi,
I have list of surnames and names in two separate files from which I try to create group of people by randomizing it.
Firstly I just sticked names to labels, added these labels to the group and later pulled one random name from it as the player name. That worked.
Later as the number of properties of that people will inevitably rise I created the class Human and created objects from this class and also added them to the group. Now I get the error when I try to get that "Player" name. Obviuosly I lack knowledge how to work with groups and objects so heeelp lol
Here is the code for creating people
func populate_village():
for i in range(40):
var Labela =labela.instance()
#Labela.add_to_group("Heads_of_Families")
Labela.bbcode_enabled = true
var human = Human.new()
human.Name = get_me_name("male")
human.Surname = get_me_name("surname")
human.Age = randi() % 45 + 15
human.add_to_group("Heads_of_Families")
Here is the code for choosing one of them
func choose_one():
Heads = get_tree().get_nodes_in_group("Heads_of_Families")
Child = Heads[randi() % Heads.size()]
childName = Child.Name
Child.set("custom_colors/default_color",Color(1,0,0))
Child.text = childName
The error comes at 4th line childName = Child.Name
Invalid get index Name on baseNode2D