0 votes

I am re-adding this question to help anyone finding the same issue, because my original question that I found this, had a mislead title. Why? Because I couldn't find anything to help me with this specific problem.

If you set a dictionary like:

var TITLE = loadedDate[0][2]#Just a example of a array stored with the Title

Library[TITLE_CATEGORY] = TITLE
Library[TITLE_CATEGORY][TITLE] = "Subtitle"

It will return a error like:

Invalid set index 'TITLE' (on base: 'String') with value of type 'String'.

asked May 16 in Engine by The_Black_Chess_King (265 points)

1 Answer

0 votes
Best answer

Because TITLE was set only as a string, the loadedDate[0][2] is just a string. So it was trying to add a dictionary subkey to a string,

The correct way of doing it is to keep it a dictionary if you want to add sub-keys:

Library[TITLE_CATEGORY] = {TITLE:"Subtitle"}

Now TITLE is a dictionary and can be referenced properly:

Library[TITLE_CATEGORY][TITLE]
answered May 16 by The_Black_Chess_King (265 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.