Javatpoint Logo
Javatpoint Logo

Dictionaries- Adding a story template

Dictionary type. Associative container contains values referenced by the unique keys. The reference always passes dictionaries.

Erasing elements while iterating over them is not supported in Godot.

Creating a dictionary:

To add a key to an existing dictionary, access it like an existing key, and assign to it:

This is a perfect way of dealing with things like inventory management, not just inventory management all kinds of things we can do this is a good use case. Here we understand that how does it help us in our game.

For making a dictionary we have a function called My_ dictionary = { }.

Now, if we had an array, would have value one too.

If we have a dictionary, we have key values.

We can have an array of string also.

Example:

Output:

Dictionaries- Adding a story template

After that complete the story.

Complete Code using dictionary:

In output section we have many stories will come continuously. We have to just add our words.

Output:

Dictionaries- Adding a story template
Dictionaries- Adding a story template
Dictionaries- Adding a story template
Dictionaries- Adding a story template

And we can make many stories as above.

In our next tutorial, we learn about StoryObjects.






Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA