I assume, that you have 10 child TextEdit nodes.
You can access child nodes by index with the function get_child()
So your code should loop on the index and inside the loop it could look something like
Well, according to your code perhaps you need to rename the first TextEdit to TextEdit1, and the index of IndividualLetters is 1 smaller than index of TextEdit.
for i in range(10):
get_node("TextEdit" + str(i + 1)).text = IndividualLetters[i]
I think the problem is the .text not working because when i type that there is no prompt for me to press tab and then it auto finishes which makes me feel like it isnt doing anything. Like i cant acces the property’s of the node
No that’s just autocomplete. The editor cannot guess what the type of get_node("TextEdit" + str(i + 1)) is, it’s normal, and it still has a text property. The problem is in naming it, your first TextEdit doesn’t have a number, but the script assumes it’s named TextEdit1. That’s why they recommend renaming it here:
The first suggestion should work fine too, let’s combine these two suggestions.
for index in range(10):
get_child(index).text = IndividualLetters[index]
I think the problem was because the array, IndividualLetters, was empty/ null. Is my code here not working? Answer is a string and i was trying to put each bit of the array as each individual letter.
while digit < Answer.Length():
IndividualLetters[digit] = Answer[digit]
digit += 1
This says Godot couldn’t set “text” on a null instance to a string
null.text = "string" #error!
The problem being null, your IndividualLetters shows it was populated by some string. You could try printing it in full, see what print(IndividualLetters) gives you.
You are right, IndividualLetters is populated however when i run this new code the first 3 letters of it seem to be disregarded and the first TextEdit has the 4th letter of IndividualLetters and 2nd TextEdit has the 5th letter of IndividualLetters and so on.
The rectangles are the TextEdit’s and the big box is where the player put’s there word. next to it is a button you press after you’ve finsished your word. I then want to display the word into individual letters per TextEdit.
Awesome! I assume you are using the get_child method; the first three children of your “Background” node are the AnswerBox, DoneButton, and AnswerButton. It will set those texts first. I recommend putting all of your TextEdits as children of one new node, like so.
Now you can use this inner “Control” node’s children only.
for index in range(10):
$Control.get_child(index).text = IndividualLetters[index]