With the release of our new Economy system, we’ve introduced some new concepts to the LootLocker platform that need to be understood to have the best experience possible.
This guide will provide some details on how the Economy system works and how to implement it easily into your own game.
We will start off by looking at how to create a Currency, and after that we will continue with creating a Catalog and a Listing, and finally we’ll look at three different examples of game implementations with this setup. If you haven’t already read our introduction to the new Economy system, make sure you do!
Alright, let’s dive right in!
Before doing anything with the Economy system, we first need to create some type of Currency. So, let’s start off by creating a Currency called Gold that we’ll use in the following examples. Doing this is simple and easy:
Navigate to Content->Economy->Currencies and click Add Currency
Add the required information for the new Currency (Gold, Code and Minor Unit Name)
Great, we now have a Currency set up, so how do we get this information in our game then?
All Currencies a player owns can be viewed in the player's Wallet. All players have a Wallet, regardless if they have any Currency or not, so you never need to create a Wallet, it’s already there - how convenient!
To view the player’s Wallet in-game, we must first get the player’s ULID, this can be retrieved when the player logs in:
Now when we have the logged in player’s ULID, we can get the players wallet ID by using the below function and specifying the type of wallet:
Great, the player now has a Wallet, but if we check the player’s Wallet with the below function:
We see that we get an empty array back. But oh no, the player has no money!
Disclaimer: For the sake of simplicity we will let the game modify our Gold currency from the game client, but keep in mind that this opens up the possibility of malicious players altering this Currency by sending in their own requests. We recommend that you handle Currencies on a server and use our Server API if possible.
On our Gold Currency, we click the “three dots” and select “Enable Writes”, this lets this Currency be modified from the Game API.
And with that fixed, we just use the function CreditBalanceToWallet() and send in the amount of Currency we want the player to have:
If we want to remove Currency from our player, we use the function DebitBalanceToWallet() instead:
Alright, we now have the player’s Wallet, we’ve added Gold to it, but now comes the question… What should we use it for?
An in-game shop is probably the most obvious system to use the Economy system for, so let’s start by creating a simple shop!
Create a new Catalog
Create a new Listing by selecting an Asset. Then select the Gold currency, add a Price and select Create Listing
When the player wants to buy something from the shop, you just need to provide the catalog_listing_id and the amount of the specified listing that they want, and if they have the required amount, the Asset (or Currency) will be added to the player's Wallet or Inventory (depending on what they buy).
Depending on how you want to create and structure your shop, you can do this in different ways:
Take the Catalog_Listing_ID directly from the LootLocker Web Console
Use the following code to list all purchasable Assets from a specific Catalog:
(You can also list all available catalogs with “ListCatalogs(Action onComplete)”). Then when the player wants to purchase something, we just call the function “LootLockerPurchaseCatalogItems()”.
Now, an in-game shop is only one of the use-cases for an Economy system, so let’s continue with another example!
It might seem strange to make a Crafting system with an Economy system, but if you think about it, when crafting something, you’re simply exchanging one resource for another - just like when making a purchase - so from an implementation perspective there is actually no difference between the two. So, say that we want to make a Crafting system that allows us to make a sword from two wood and three iron resources.
The setup on the LootLocker dashboard is the same as with a shop, we will be using resources (Currency) to buy an Asset.
Create two new Currencies: Wood and Iron
Create a Catalog
Add a new listing, select an Asset to craft, and add the price of 2 Wood and 3 Iron
For the implementation part, it is the same as with the store, you buy the asset by using the resources:
Doing it like this creates a one-way Crafting system, meaning that once crafted, the item can not be made back into the previous resources. You can however set that up as well, by instead of crafting an asset, let the player craft a resource instead.
Create two currencies: Iron and Sword
Create a Catalog
Add a Listing for 1 Sword Currency for 3 Iron Currency
Add another Listing for 3 Iron Currency for 1 Sword Currency
With this system, the players will be able to both craft the resource and break it down into the previous component as well, it’s all just a matter of trading one resource for another!
The implementation part in your game does not need to be any different either, but instead of displaying the player’s Inventory, you would display the player’s Wallet to show what “resources” they currently have.
While you can implement a skill tree using only our Progression system, you can create a more flexible version of a skill tree by combining a Progression system with our Economy system. When using only Progressions, the player will add one point to a Progression, but if they instead “buy” a point in a Progression using Currencies they have the possibility to apply the Progression point to several different Progressions.
Setting this up is simple and easy as well!
Create one or several Progressions
Set up a few Tiers with the cost of 1 between each Tier
Create a resource (SkillPoints for example)
Set up a new Catalog
Add a new listing, select “Progression Points” and choose your previously created progression
With this setup, the player can acquire one type of Currency that they can then choose to spend on any of the Progressions available, allowing for more complex and future-proof skill Progressions than with just a regular Progression.
And when the player wants to go one step in any of your skill Progressions, they just need to buy that specific Listing from the Catalog, so for the implementation, it’s the same as buying anything else!
Note: Remember to request an update of the Progression that you altered if the purchase is completed!
And, that’s all for this little guide!
You should now have all the necessary information to create complex systems using our Economy (and Progression) system! Remember that in the end it’s just resources being traded for other resources, so it can be used for almost anything! Reach out if you have any questions and please share with us if you make something cool with it, we’re always eager to see what our users are doing!
If you're looking for links to get started, you can find them below.
API Reference Documentation:
If you get stuck, join our Discord community and ask for help! You can also find us on Twitter.