Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
gdevelop5:all-features:inventory [2018/10/16 20:18]
valiant_curiosity [Saving/loading inventories]
gdevelop5:all-features:inventory [2019/05/21 20:01] (current)
piyushpalawat99
Line 9: Line 9:
 ## Adding, removing and manipulating items. ## Adding, removing and manipulating items.
  
-Inventories are composed of items. As mentioned above, the default "​Inventory" ​is empty of any items.+Inventories are composed of items. As mentioned above, the default "​Inventory" ​does not have any items.
  
-Use the action "Add an item" to add an item to the inventory. The name of the item can be choosen ​freely. For example, an "item could be "​Sword",​ "​Gold",​ "​Bullets",​ etc.+Use the action "Add an item" to add an item to the inventory. The name of the item can be chosen ​freely. For example, an item could be "​Sword",​ "​Gold",​ "​Bullets",​ etc.
 You can also use the action "​Remove an item" to remove one item in an inventory. You can also use the action "​Remove an item" to remove one item in an inventory.
  
 You can set limits on the items of an inventory by using the action "Set a maximum count for an item". Enter the item name and the count. When an item has reached its maximum count, adding new items won't increase the count of the item in the inventory. You can set limits on the items of an inventory by using the action "Set a maximum count for an item". Enter the item name and the count. When an item has reached its maximum count, adding new items won't increase the count of the item in the inventory.
  
-You can use the conditions "Item full" to check if an item reached the full capacity. The  condition "Has an item" allows a check to be made of the inventory to see //if// the player has at least one of the specified items.+You can use the conditions "Item full" to check if an item reached the full capacity. The condition "Has an item" allows a check to be made of the inventory to see //if// the player has at least one of the specified items.
  
 ## Setting an item as equipped ## Setting an item as equipped
  
-Items can be marked as "​equipped"​. Use the action "Equip an item". This action doesn'​t change anything in the game. However, you can use the condition "Item equipped"​ to check to see //if// an item is equipped. Then you can set your action accordingly.+Items can be marked as "​equipped" ​using the action "Equip an item". This action doesn'​t change anything in the game. However, you can use the condition "Item equipped"​ to check to see //if// an item is equipped, then you can set your action accordingly.
  
 For example, you can use the condition "Item equipped"​ to check to see if a "Magic Sword" in your game is equipped. If it is equipped, ​ you might add more damages to the enemies. For example, you can use the condition "Item equipped"​ to check to see if a "Magic Sword" in your game is equipped. If it is equipped, ​ you might add more damages to the enemies.
Line 26: Line 26:
 If an item reaches the count of 0 (i.e: the inventory is empty of items), it is not marked as equipped. If an item reaches the count of 0 (i.e: the inventory is empty of items), it is not marked as equipped.
  
-## How to display the items of an inventory in the  game. +## How to display the items of an inventory in the game. 
  
-Different games can display inventories in different ways. Inventories can't be rendered directly on the screen, but you can use  [[gdevelop5:​objects:​sprite|Sprites]] ​ [[gdevelop5:​objects:​text|Text objects]] to create your own display.+Different games can display inventories in different ways. Inventories can't be rendered directly on the screen, but you can use [[gdevelop5:​objects:​sprite|Sprites]] ​and [[gdevelop5:​objects:​text|Text objects]] to create your own display.
  
 To use Sprites and Text objects to create a display: ​ To use Sprites and Text objects to create a display: ​
Line 34: Line 34:
   - display or hide the associated object on the screen ​   - display or hide the associated object on the screen ​
   - use the expression "Item count" (for example, `InventoryTools::​Count("​PlayerInventory",​ "​Gold"​)`) to access to the count of a given item    - use the expression "Item count" (for example, `InventoryTools::​Count("​PlayerInventory",​ "​Gold"​)`) to access to the count of a given item 
-  - use the "Item count" to set the text of a "​Text"​ object that is displayed on screen+  - use the "Item count" to set the text of a "​Text"​ object that is displayed on the screen
  
 ## Saving/​loading inventories ## Saving/​loading inventories
  
-Use [[gdevelop5:​all-features:​storage|storage actions]] to save the progress of the player. ​ You can also save the content of the inventory (or any other inventories that you use in the game).+Use [[gdevelop5:​all-features:​storage|storage actions]] to save the progress of the player. You can also save the content of the inventory (or any other inventories that you use in the game).
  
 The actions "Save an inventory in a variable"​ and "Load an inventory from a variable",​ allow you to dump the contents of an inventory into a variable. These actions will be set as a structured variable. The information will be contained as children. The actions can also be used to restore an inventory from a variable. The actions "Save an inventory in a variable"​ and "Load an inventory from a variable",​ allow you to dump the contents of an inventory into a variable. These actions will be set as a structured variable. The information will be contained as children. The actions can also be used to restore an inventory from a variable.