Equip resources on characters
Introduction
Honeycomb Protocol lets the characters in your game equip, or even consume, items that can improve their stats. These items can be weapons or armor, and even consumables like potions.
In this guide, we'll show you how to equip resources on your characters.
Pre-requisites
Before following this guide, please make sure you do the following:
Step by step guide
At this point in the guide, we'll assume you have a character and a resource in your project. If you don't, please follow the pre-requisites above.
Once you have those, you can follow the steps below to equip resources.
1. Equip a resource
Here's how you can equip a resource on a character:
const {
createEquipResourceOnCharacterTransaction: txResponse // The transaction response that you have to get signed and send the transaction
} =
await client.createEquipResourceOnCharacterTransaction({
characterModel: characterModelAddress.toString(), // The address of the character model
characterAddress: characterAddress.toString(), // The character the resource is being equipped to, this character should be owned by the user (owner)
resource: resourceAddress.toString(), // The address of the resource being equipped, this should be resource that exists in your project and the user (owner) has in their inventory
owner: userPublicKey.toString(), // The public key of the owner
amount: "1", // The amount of the resource being equipped to the character
});
2. (Optional) Unequip a resource
const {
createDismountResourceOnCharacterTransaction: txResponse // The transaction response that you have to get signed and send the transaction
} =
await client.createDismountResourceOnCharacterTransaction({
characterModel: characterModelAddress.toString(), // The address of the character model
characterAddress: characterAddress.toString(), // The character the resource is being unequipped from, the character must have the resource (given below) equipped
resource: resourceAddress.toString(), // The address of the resource being unequipped
owner: userPublicKey.toString(), // The public key of the user who owns the character and the resource
amount: "1", // The amount of the resource being unequipped
});