Haxe listener function to receive events from external SDK

Hello haxe community, hope to get a bit of help regarding an issue I can’t figure out myself.

My name is Adrian and I develop html5 games using the Stencyl game engine wich basic coding language is Haxe. Although Stencyl is quite easy to use by using drag and drop blocks in order to build the logic for the games yet at some point you need Haxe coding skills in order to implement specific tasks that hasn’t yet been implemented as drag&drop blocks or extensions.

Currently I’m stuck when it comes to hardcode a Haxe function that communicates with an external SDK the to be more precise

Basicaly the SDK it’s initialized once inside the index.html of the exported game by setting it’s server path using javascript.

Once the user starts to play the game at same point “after a life is lost for example” when he clicks the “Play again” button an advertisement is triggered - this part is solved and working correctly

So here comes the part where I need help coding a listener function that will receive events from the SDK as when an advertisement is shown to the user - to pause the game and mute sounds and once the ad is closed to resume the game.

Searching online I found this piece of code that does exactly what I need except it uses LUA coding language so I’m asking if someone here would be willing to help by rewriting it in HAXE:

gdsdk.set_listener(function(self, event, message)
    print(event, message)
    if event == gdsdk.SDK_GAME_PAUSE then
        -- pause your game - 
    elseif event == gdsdk.SDK_GAME_START then
        -- resume your game
        elseif event == gdsdk.SDK_REWARDED_WATCH_COMPLETE then
                -- give reward to player (optional)

The functions for Pausing and Resuming the game are prebuilt in Stencyl and can integrate them myself.

Kind regards to all and many thanks in advance to everyone taking time to read this post and give some help.

There’s a GameDistribution extension available for Stencyl, but it requires Stencyl 4.1.0 which isn’t publicly available yet.

The parts that rely on Stencyl 4.1.0 are noted in the top part of this commit’s message. If you remove those bits and instead hardcode your gameId in the index.html template, you should be able to use this with Stencyl 4.0.4.

Additionally, the code attribute type used by some of the blocks (in blocks.xml) is not available in Stencyl 4.0.4. To make that work, you can use this toolset extension, which you can download prebuilt within Stencyl by Extensions > Extension Repositories, and entering the repository

Alternatively, if you’re a Stencyl subscriber, you can just download the latest beta release and use the extension as-is.

I’m available in the Stencyl discord if you have any more questions about the Stencyl-specific parts of this.

1 Like

Justin thank you thousands of times for your kind support, currently I’ve only developed 4 games using the Stencyl engine, it was a learn and build experience at the same time, yet I really like to use Stencyl I find it easy and intuitive and I always found help on forum and discord, I asked about this issue of mine also, but probably got under the radar :).
As I managed to raise some money I will switch to the Indie subscription plan by the end of this month.
If I will get stuck trying to use the extension on my current 4.0.4 version will contact you on Discord for sure.
Thanks again and best wishes to you and the whole Stencyl team !!