The inventory is the UI that shows your current inventory items, and allows you to use them. It is located in the scene file ui/inventory.scn. The inventory will show items from a scene that contains all the items in your game. Items can be shown in multiple pages.
The requirements of the inventory scene are as follows:
Escoria provides a default inventory scene you can find in game/inventory_items.scn. This scene contains a basic item but needs to be customized to add all the items of your game as children of a root Node2D node. The items must be fully functional Items, configured with their properties, sprite, script file, etc. For this type of item, usually a TextureButton is used with the globals/item.gd script attached to it, although any other type of item can be used. You can read "The Items" Chapter for details.
The inventory scene is a child of hud.scn which is a chid of game.scn. So it should be made available automatically in your game once game.scn in imported to your main scene. Refer to our Create your scene chapter to see how to do it.
Now that the inventory is ready as a UI element visible to the user, it will be necessary to define how to use it. This will be done with an esc script description. Generally, adding an element to the inventory will be made from a pick_up action. During this action we generally have to :
In the script it could look like this example we use in our intro game.
set_global i/inv_good_bamboo true
set_active good_bamboo false
Note that, since we add items to the inventory, we can use the global flag corresponding to the item to check if the user has it
# user has the good bamboo
Usually, using an inventory item will be used on a :use action
and you will probably need to unset all the necessary globals, conversely to the pick up action
Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.
Vous devriez rafraîchir la page.