Will JS code run from the custom code blocks for SDK implementation?

svnriz

  • Posts: 17
Hello,
This is my first time trying to integrate anything outside of Stencyl extensions into my HTML5 game.
A.jpg in the attachment is the javascript code I need to put in the game to run the SDK I want.
B.jpg is what I tried doing but it shows the error type not found Rune
How do I make this work with blocks or do I have to edit some file after publishing?

Justin

  • *
  • Posts: 4644
Haxe doesn't know anything about Rune since you haven't created any Haxe externs for it. Perhaps try wrapping "Rune" inside "js.Syntax.code" to directly access it in the generated Javascript code instead.

js.Syntax API docs

Code: [Select]
js.Syntax.code("Rune").init({
  resumeGame: myResumeGameFunction,
  pauseGame: myPauseGameFunction,
  restartGame: myRestartGameFunction,
  getScore: myGetScoreFunction
});

I'm not positive that that will work, just the first thing I might try.

I took a quick look at the Rune SDK (linked for myself and others), and it says you need to load some javascript before anything else:
Code: [Select]
<script src="https://cdn.jsdelivr.net/npm/rune-games-sdk@2.5.0/dist/browser.min.js"></script>

You may be able to get away with adding that as a dependency in Settings > Advanced > OpenFL Settings.
Code: [Select]
<section if="html5">
    <dependency name="https://cdn.jsdelivr.net/npm/rune-games-sdk@2.5.0/dist/browser.min.js" />
</section>

Otherwise, you may need to create an engine extension with a modified index.html template. Here's an example of an almost blank HTML5 engine extension with an index.html template set up.


You may find it helpful to browse other HTML5 engine extensions that handle integration with different javascript SDKs, so here are a couple that I wrote:
- GameDistribution
- CrazyGames
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

svnriz

  • Posts: 17
Thank you for the reply Justin.
I really don't understand code be it haxe, javascript or otherwise.
I know how to edit the index.html to add the <script> but that's about it.
Is there any way to make this work with just blocks or by just adding some lines to the .html or .js files ?
Making an extensions is a bit out of my scope.