Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Robster | |
Old Version | Published before Godot 3 was released. |
Hi all,
I have a JSON file that describes my characters.
I have a character select screen and it loads the JSON data to feed the interface and allow you to cycle through the characters.
I want to be able to say, only show characters with X attributes and Y attributes.
So I have a function like so:
func loadCharacters(X, Y):
var file = File.new()
file.open("res://json/characters.json", file.READ)
var text = file.get_as_text()
dict.parse_json(text)
file.close()
#get how many are in results
get_node("LabelCharactersNumTotal").set_text(str(dict.size()))
# print something from the dictionary for testing.
print(dict["3"])
So that all works as a base test which is fine. The print shows the contents of the third character.
How can I get ONLY characters that have X and Y that’s being passed to the function? I have ALL the character’s info in the dict
but I want to now parse that or extract from there based on X and Y.
Any advice much appreciated.