Creating Stackable Items #
In this section, we’ll be creating a stackable item of gold coins to purchase items in a store.
Get started #
Run the following commands in the terminal from the platform directory to build the engine and make 5-ext if it doesn’t already exist:
make skip-tests protos enginemake ext
Define stackable item specs #
- Go to
5-ext/content/src/StackableSpecs.jsonand add the following code to create agold_coinsstackable item:
[
{
"catalogId": "gold_coins",
"name": "gold_coins",
"limit": 100000000,
"tags": ["currency"],
"removeIfNone": false
}
]
Stackable items are items with no special properties. Each item in the stack is identical.
Apply content data #
In order to register the content you just defined with Pragma Engine, you must apply your content data changes. You may apply content data either using the command line with make or via an IntelliJ run configuration.
Test the stackable item in Postman #
In this section, we’ll test our stackable items by running API calls in Postman.
Start Pragma Engine #
Run Pragma Engine via one of the following methods.
Once the engine has started successfully, it prints the message [main] INFO main - Pragma server startup complete.
Simulate granting a player a gold coin #
- Open Postman.
- Navigate to the two service calls
PragmaDev ➨ Public ➨ Operator - AuthenticateOrCreateV2andPragmaDev ➨ Public ➨ Player - AuthenticateOrCreateV2. - Click Send for both service calls and check that the response body for each call has
pragmaTokenswith a filledpragmaGameTokenandpragmaSocialToken. - Open
Game➨RPC - Operator➨Inventory➨GrantItemsOperatorV1and edit the body with the following payload:
- Find the
stackableobject and fill thecatalogIdwith the valuegold_coins. - Then fill the
amountwith a value of1.
- Click Send and check the response body to see if
gold_coinsare present in the object’s delta and segment payloads. If the amount ofgold_coinsis now1, we have successfully granted a gold coin to our player.