Request: GameJolt API?

AdventureIslands

  • *
  • Posts: 728
I would like to include GameJolt API to my games so I could add stuff like achievements, but I don't know which option from this list to pick: http://gamejolt.com/developers/achievements-new/ nor do I know how to actually implement it. Could someone help me out a bit here how to do this?


« Last Edit: January 24, 2014, 02:07:38 am by Jon »

rob1221

  • *
  • Posts: 9430
There are two ways of doing this.  The first is to convert all of the code to Haxe.  The second is to compile the source file into a SWF and then call the functions from Haxe (see test-flash extension).


Hypnohustla

  • Posts: 163
Has anybody been able to implement this?
Follow me on Twitter

Jon

  • *
  • Posts: 17524
That API that George linked to is really simple. Someone could wrap it as an extension and provide a couple blocks to call its functionality, and even that would be unnecessary.

Hypnohustla

  • Posts: 163
I'm just afraid of screwing something up with my low level knowledge of these kind of things. :P I guess I have to check more into it.
Follow me on Twitter

Jon

  • *
  • Posts: 17524
For the lazy, this is how you can do it sans extension, but for the community's sake, an extension would be much better.

1) Create a freeform mode behavior. See attached screenshot.

2) Paste the source in.
https://raw.github.com/bsinky/gjhaxeAPI/master/api/GJAPI.hx

3) Use it using a tiny bit of code. For example, to submit a score, do something like this (see their code to see what the exact parameters are to pass in).

Code: [Select]
var api = new api.GJAPI();
api.addScore("MYGAMEID", "100", "DESC", "ASDFGHJ123");

I don't know exactly how this API works or what it wants, but they (as in GJ) should have some docs on this.

The nice thing about this is that this should work on all platforms. It isn't restricted to Flash at all.

Hypnohustla

  • Posts: 163
Ok you really are one heck of a nice guy. Wasn't expecting this. :D I'll report how this pans out.
EDIT: Currently too tired to get anywhere with this, I have to get some sleep. :) Wished to add some trophies to my game, should not be too hard but I'll check back tomorrow.

« Last Edit: October 24, 2013, 02:12:27 pm by Hypnohustla »
Follow me on Twitter

Hypnohustla

  • Posts: 163
Okay, I officially feel like an idiot trying to do this by myself.

Code: [Select]
api.achieveTrophy(game_id:string, username:String, user_token:String, trophy_id:string, game_key:String);
I understand most of it but what exactly should I but in the username and usertoken parts. Trying to read the docs but I'm just confusing myself more.

The reason I love Stencyl is that I dont have to usually do these kind of things. :D
Follow me on Twitter

rob1221

  • *
  • Posts: 9430
Quote
Flash games are automatically passed the username and token in flashvars.

http://gamejolt.com/api/doc/game/users/

Hypnohustla

  • Posts: 163
So it should just look something like this?

Code: [Select]
api.achieveTrophy("1234567", "username", "user_token", "1234", "123456789abcdefg");
Follow me on Twitter

rob1221

  • *
  • Posts: 9430
You have to pull the data from the flashvars somehow.  I'll look at this later.

Hypnohustla

  • Posts: 163
Please do, would really help a noob like me :)
Follow me on Twitter

rob1221

  • *
  • Posts: 9430
I found this post talking about it: http://gamejolt.com/community/forums/topics/as3-trophy-api/305/?forum_topic_post_page=2#forum_topic_posts

So based on that post I'm guessing you would get the username with
Code: [Select]
LoaderInfo(flash.Lib.current.loaderInfo).parameters.gjapi_username;The token would be gjapi_token rather than gjapi_username.

Hypnohustla

  • Posts: 163
I'm getting an unknown identifier error. So I have to dig around more :)
Follow me on Twitter