A new Player Data service has been released that is more up to date and supported with this current release of Pragma Engine. We recommend you check it out by viewing the Player Data Overview page.
Crafting #
Crafting systems range from a simple exchange of materials for gear, to complex, nested, pseudo-random rolled item grant and upgrade systems. Pragma Engine is designed to enable simple workflows powered entirely by content and configuration, and rich workflows with custom game logic defined in plugins.
To learn more about how crafting fits into our larger content systems, as well as how to access crafting content catalogs in Portal, visit the Content Data services page.
Crafting Plugin #
The Crafting Plugin is used to define custom crafting behavior and enable programmatic inventory transformations. In the following sections, we’ll take a look at the different components that make up the Crafting Plugin’s interface.
Member | Section |
---|---|
meetsRequirements | Defining requirements |
craft | Defining the craft function |
InventoryModifications | Returning the result |
Define requirements #
When the Crafting Plugin is called, the meetsRequirements
function is the first to be executed. This function is used to create custom requirements for a craft request. If the requirements are not met, meetsRequirements
returns an error message and the craft
function is not performed.
Parameter | Description |
---|---|
craftingEntry | The content crafting entry. |
destroyedInstancedItems | The list of instance items that would be destroyed if the craft were performed. |
playerInventory | A snapshot of the player’s current inventory data. |
requestExt | Your custom defined proto containing details about the current craft operation. |
Define the craft function #
The craft
function is used to perform programmatic inventory transformations.
Parameter | Description |
---|---|
craftingEntry | The content crafting entry. |
destroyedInstancedItems | The list of instance items that would be destroyed if the craft were performed. |
playerInventory | A snapshot of the player’s current inventory data. |
inventoryContent | All inventory content for reference purposes. |
requestExt | Your custom defined proto containing details about the current craft operation. |
Return the result #
The craft
function must return a InventoryModifications
. This data class can be to used for chaining of additional operations such as granting, updating, or destroying items. Below are the possible item operations:
Property | Type | Description |
---|---|---|
rewardGrants | List<RewardGrant> | List of rewards to be granted. |
instancedItemServerGrants | List<InstancedItemServerGrant> | List of instanced item to be granted. |
stackableItemGrants | List<StackableItemGrant> | List of stackable item grants to be granted. |
serverInstancedItemUpdates | List<ServerInstancedItemUpdate> | List of instanced items to be updated. |
instancedItemsToDestroy | List<InstanceId> | List of instanced items to be destroyed. |
Basic crafting #
The Store system works in a pinch to support basic crafting systems as well. This means crafting can be implemented directly through content and configuration.
It can be helpful to think of the store system as a simple crafting system. You can define as many store catalogs as needed, and the in-game UI could be anything from an NPC shopkeeper to a workbench to an in-game menu.
Advanced crafting #
Some games have more involved crafting systems with custom requirements or initialization logic. The Craft system provides a very powerful, flexible API through the Craft
plugin.
For full examples, see the Crafting Tutorial.