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.
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 engine
make ext
Define stackable item specs #
- Go to
5-ext/content/src/StackableSpecs.json
and add the following code to create agold_coins
stackable 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 - AuthenticateOrCreateV2
andPragmaDev ➨ Public ➨ Player - AuthenticateOrCreateV2
. - Click Send for both service calls and check that the response body for each call has
pragmaTokens
with a filledpragmaGameToken
andpragmaSocialToken
. - Open
Game➨RPC - Operator➨Inventory➨GrantItemsOperatorV1
and edit the body with the following payload:
- Find the
stackable
object and fill thecatalogId
with the valuegold_coins
. - Then fill the
amount
with a value of1
.
- Click Send and check the response body to see if
gold_coins
are present in the object’s delta and segment payloads. If the amount ofgold_coins
is now1
, we have successfully granted a gold coin to our player.