0 votes

I store multiple data in a variable called "data":

data = {
"Lap Time" : newBest, 
"Player" : userName, 
"Circuit" : int(get_tree().current_scene.name.right(6))

My question is, how do I check each data?

Say, I want to check "Lap Time", can you please show me an example how it can be called/accessed?

Thank you for your time!

Godot version 3.2.3
in Engine by (327 points)

Never mind, got it.


1 Answer

0 votes
Best answer

As you can see in the godot's dictionary documentation, you should get the value of the dictionary object and if it returns null, it does not exists.
If it exists, then you can check its value with the same function or with data["Lap Time"]
An example:

if(data.get("Lap Time") != null):
   print("Lap Time exists and its value is %s", data.get("Lap Time"));
   print("Lap time doesn't exists");

I hope this will be useful for you.
MxtApps :)

by (115 points)
selected by
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.