View as Markdown

Inventory

Read more about the Inventory system in Hiro here .

List items #

List all inventory items defined in the codex, optionally filtered by category.

1
2
3
4
5
var request = InventoryListRequest();
request.item_category = "weapons";

var inventory_list = await hiro.inventoryList(session!, request);
print(inventory_list);

List user inventory items #

List all inventory items owned by the player, optionally filtered by category.

1
2
3
4
5
var request = InventoryListRequest();
request.item_category = "weapons";

var inventory_list = await hiro.inventoryListInventory(session!, request);
print(inventory_list);

Consume inventory items #

Consume one or more inventory items owned by the player.

1
2
3
4
5
6
7
var request = InventoryConsumeRequest();
request.items = {
    "health_potion": "1"
};

var consume_rewards = await hiro.inventoryConsume(session!, request);
print(consume_rewards);

Grant inventory items #

Grant one or more inventory items to the player.

1
2
3
4
5
6
7
var request = InventoryGrantRequest();
request.items = {
    "bronze_sword": "1"
};

var grant_rewards = await hiro.inventoryGrant(session!, request);
print(grant_rewards);

Remove inventory items #

To remove items from a user’s inventory, without consuming them, use a negative grant value.

1
2
3
4
5
6
7
var request = InventoryGrantRequest();
request.items = {
    "bronze_sword": "-1"
};

var grant_rewards = await hiro.inventoryGrant(session!, request);
print(grant_rewards);

Delete item instances #

Delete a specific item instance by its instance ID, rather than reducing its stacked count. Use this for non-stackable items, or items whose instance carries state that a count can’t represent.

1
2
3
4
5
var request = InventoryDeleteItemsRequest();
request.instanceIds = ["<instanceId>"];

var ack = await hiro.inventoryDelete(session!, request);
print(ack);

See Removing items for when to choose this over a negative grant.

Update inventory items #

Update the properties on one or more inventory items owned by the player.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
var request = InventoryUpdateItemsRequest()
request.item_updates = {
    "bronze_sword": {
        "string_properties": {
            "example_property": "example_value"
        },
        "numeric_properties": {
            "numeric_properties": 10
        }
    }
};

var update_ack = await hiro.inventoryUpdate(session!, request);
print(update_ack);