GameJolt API plugin for Construct 2 updated

GameJolt API plugin for Construct 2

Today I'm proud to announce, that my GameJolt API plugin for Construct 2 has been finally updated to support most of site's functions.

This means that you can now display highscore tables and trophies in your game, access Data Store, and more.

You can get the updated extension and example from the GameJolt page, or read this post for few more details.

Firstly, to mention why there was such a delay between initial release and this update.


Making easy to use Construct 2 plugins can be a bit of a trouble sometimes.

While the fact that you define UI and runtime parts of plugin separately is generally good, it also means that the process takes more time on average, since you need to define everything twice and also ensure that you did not make any mistakes and everything works as intended on both sides.

Another trouble is interface. For a plugin like GameJolt API you send data to site, and wait for response. Response is normally handled either synchronously (meaning that game freezes while it's waiting for a response) or via a callback function (that is called as soon as response arrives).
In Construct 2, however, you (by default) only have events, which are kind of like callbacks, but are global, and don't support arguments.

So... what I ended up doing after a while, is having global variables that allow you to determine, what the event applies to, dispatching the event, and having good faith in you not trying to access the variables outside of their respective events.
Anyway,

Additions

Highscores

You can now fetch contents of any given highscore table.
Mechanism is as following:

  1. You request highscores to be fetched via Scores - Get Scores (or Get Local Scores to get highscore table entries just for the current player).
  2. Extension forms and sends the request, and waits for response to arrive.
  3. Extension dispatches a Score - Scores received event. At this time you have ScoreTable to know which table the scores are coming from, and ScoreCount determining number of returned scores (in case you need to prepare for handling them).
  4. Extension dispatches series of Score - Score entry events, one per every score entry. These contain the multitude of variables starting with Score and correspond to individual score entry information. ScorePlace contains index/place of score entry in table, starting with 1 and ending at ScoreCount (inclusive). ScoreTable remains set and still can be used to distinguish score tables
  5. Extension dispatches a Score - Scores complete event to mark the fact of all score entries being processed.

Score submitted event has also been updated and now sets some of Score* variables, but only ones that have been provided in action itself (because GameJolt does not respond with information like place achieved).

Trophies

You can now also fetch trophy status(es) for your game.
The mechanism is very alike to that of scores, except for lack of "received"/"complete" events.
An important thing to note here is that you can provide trophy IDs as a comma-separated list, e.g. "5980,5981,5982".
"Trophy achieved" callback only gets to know TrophyID, and TrophyAchieved, which is set to "just now" if trophy achievement was confirmed, and an empty string if it failed.

Data Store

Finally, there are now functions and events to work with Data Store. Data Store is awesome.
Possibilities are almost endless, and are primarily only limited by your imagination & creativity.

Each Data Store action dispatches an according event of it's own, containing StoreKey (and StoreLocal) to allow telling requests apart, and StoreValue containing new or retrieved value.

It is also worth mentioning, that "update" events also return (updated) values, meaning that you don't have to spend an extra request to retrieve the new value.


You can get the updated extension and example from game's page, or via these links of fair convenience:

Extension Example (CAPX)

As usual, you can ask any questions, if needed.
And if you like what I'm doing, consider supporting me on Patreon :)

Related posts:

6 thoughts on “GameJolt API plugin for Construct 2 updated

  1. Hello there! I have a problem with downloading the extension. When I try to download the file, it says:

    —–

    “A problem”

    “The requested resource does not exist.
    If you came here from the blog, please leave
    a comment and I’ll see about fixing the link.”
    —–
    If possible can you please fix this? Thanks.

  2. Hi! Thanks for the plugin. But is there a manual how to add it? Whats the “Auth” action, what are Sessions? Do I need to “log in” with “On Start of Layout” or how does it work? The example has a “On Login” action, so does it login automatically?

    The example capx did not work for me. I did not see scores or trophies.

    • By doing “Add score of VariableName VariableName to table 0″ after having added a highscore table to the game. See example or the first picture in the original post. If something does not work, try uploading your game to GameJolt first (and testing on page).

Leave a Reply to Caspert Van Oosten Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.