Skip to content
WinterBlox edited this page Nov 5, 2023 · 6 revisions

Setting up FrostJolt

Setting up FrostJolt for your GameMaker Project is fairly simple. All we need to do is change some macros and add some objects, and you'll be ready to start using FrostJolt to spice up your game with Game Jolt's Game API!

Setting the Macros

To start, we need to tell FrostJolt what game it will be making calls for. To do this, look for the ext_frostjolt Extension in the FrostJolt Library Folder. This was automatically imported alongside the rest of the library when you imported the Local Package.

When you get inside that Extension, it should have a number of Extension Options.

A picture containing multiple different inputs, checkboxes and dropdowns. The first two are listed under 'Required Configurations' as Game ID and Private Key.

All of these options control how FrostJolt will behave at runtime and how it will send and log requests and responses. For now, we only need to focus on the first two options: Game ID and Private Key. Both of these are located on your Game's Dashboard under Game API >> API Settings. (Note: All of these options have different tooltips that you can view by hovering over them with your mouse cursor.)

Warning

It's important to know that you should NEVER give your private key to anyone! Your game's key is used to validate that API requests are coming from your game. If any third parties get a hold of it, they can send in fake requests pretending to be your game.

Copy and paste your Game ID and Private Key into their respective extension options, and you should have something that looks like this:

The same extension options as before, but the Game ID and Private Key have both been replaced. The Private Key is blurred for obvious reasons.

Finishing Touches

The last thing we need to do to finish setting up FrostJolt is to add the obj_gjloader Object into our starting room. If you do not know what room is your starting room, it will be marked with a House Symbol.

(rm_level is the starting room in my case, but it will be different for you)

Go to the gjloader object and mark it as persistent. This way, when we switch rooms, it wont be destroyed.

Lastly, place the gjloader object into your starting room.

Congratulations! You have successfully set up FrostJolt with your GameMaker Project! From here, it's recommended to check out pages that go more in-depth on FrostJolt's other Functions. Before you do however, keep these few things in mind:

  1. All responses are stored in a Global DS List as a Backlog. This variable is named "fj_response_backlog". If you need to access a previous response, check this DS List.

  2. Remember that DS Lists are Dynamic Resources, so they do NOT destroy themselves at the end of a room or game session. Luckily, FrostJolt comes with a function to destroy all Data Structures that it uses. "fj_deinitialize". Run this in the Game End event. This is automatically run at the end of the game for you by the Extension, but for some platforms it may not work as you expect. In this case, you should run this function in the Game End event if you are affected by this issue. See the following from the GameMaker Manual:

Note

All platforms support the Init function call, but not all platforms will perform the Final function call. This is because certain platforms will simply close the app without giving any notice or time for this function to be called. The platforms mostly affected by this are iOS, Android, HTML5, PlayStation and Xbox.

  1. Keep in mind that running fj_deinitialize will destroy the backlog, essentially erasing all of your saved responses! Make sure there's nothing you need for another session in that backlog before running this function.

  2. Be wary that the server may refuse to accept your request for different reasons, ranging from sending too many requests in a short time span, or missing parameters.

  3. The response will be spat into the Output Console of GameMaker, and stored in different variables. If you have a custom in-game Developer Console, you can alter the code to make it log the response in there too!

  4. Lastly, do not spam the API with requests! It may choose to kick you out of it temporarily or block you from sending requests entirely.

Welcome to the FrostJolt Wiki!

This wiki serves at the main documentation for all FrostJolt functions and paradigms. If you would like to suggest/propose a change to this wiki, please open an Issue with the 'Documentation' Label and provide details about what should be changed.

Clone this wiki locally