The last thing I want us to do is add some code to our project.
If you go near a chest, it will open, but nothing comes out of it.
It's not spawning an item for the player to loot.
And we want to remedy that.
To do so we're going to search for the chest in our project.
And we have a Chest.tscn in Scene that we could open by double-clicking.
And this has a script attached to it.
The icon there tells you that you have some code attached to a node,
so you can click the icon to open the corresponding script.
Don't worry about the code.
You'll learn about what everything means in due time.
For now, we're just going to write a line of code
and see how it changes our game behavior.
You have these lines, func loot.
This is a function named loot.
It's code the game executes when you pass in front of the chest.
And in that function, after the second line,
_animation_player.play("loot"),
we need to create a pickup for the player.
So you're going to place your cursor at the end of the line by clicking
and then press enter to create a new line
with this leading tab here.
It's very important.
You then want to call the function called create pickup.
To do so, you type its name, starting with underscore create,
and you will get this suggestion from the engine,
which you can accept by pressing enter,
and it will automatically complete the line for you.
With that, you can press F5 to play the game and walk your character.
And as you pass in front of the chest, it will create a random pickup.
With that, you saw how to assemble a game.
There are a couple things that we could improve.
For example, in our game right now, we are missing some invisible walls.
If you want to add them, you select the invisible walls
in your main scene tab there,
and you click and drag on the cells where you want the walls,
and you right-click and drag to remove them.
Note that some walls exist in the room scenes,
which is why you cannot erase them this way.
You can just use this InvisibleWalls node
to create new walls that don't exist in the other scenes like so
and that will prevent the player from walking in the sky.
Now, this is where this little introduction project ends.
You will learn to create this game,
however, to do so, we need to first take a step back,
learn the basics of programming and create much smaller projects
and create all those parts that you saw here,
like the player, the weapon, the chest,
we'll learn to code those as separate chunks.
And you will then get to put your twist on them
and assemble them into a game that you'll make,
I hope, your own by the end of the course.
With that, in the next part, we'll talk about the learn GDScript app,
a free and open-source application that will teach you
the basics of scripting with the GDScript programming language.
See you there.