itch.io is community of indie game creators and players

Devlogs

New DOM Side Plugin

Primitives for Construct 3
A downloadable bundle

The new DOM Side plugin is now part of the suite!

With this plugin you can load scripts directly to the DOM Side and communicate with the Web Worker using a simple API of events and procedure calls.

The first thing you should do is to create a new JavaScript file inside your files/ folder (no scripts/). Then load it with a simple action.

Inside your loaded script, you have full DOM APIs.

The script doesn’t have context of your game though, so if you want to communicate between the Web Worker (where the runtime of your game is running) and the DOM Side (where you have full DOM APIs and can modify the HTML), you must use the global object DomSideHandler.

DomSideHandler is a global object that exists on both sides. With it you can listen for events or send events to the other side. You can register procedures so the other side can call them or call procedures of the other side.

Events can be listened with on or onOnce, then dispatched with send. But what if we want to execute an action that returns us a value? For that we must register procedures.

So we can register procedures with handle and call them with invoke. Just be sure that your procedures have distinct names, you can only have one procedure per name, meaning that if you register two On Handle triggers in the EventSheets with the same name, only one will run. If you need to execute multiple stuff use events.

That’s pretty much it, the plugin is simple but powerful. With it you have a way to load scripts to a limitless context and you have a simple API to communicate with your game.

Enjoy!

Files

  • demo-domside.c3p 166 kB
    11 hours ago
  • MasterPose_Vector-1.0.2.0.c3addon 10 kB
    11 hours ago
  • MasterPose_Collider-1.0.2.0.c3addon 5.5 kB
    11 hours ago
  • MasterPose_DomSide-1.0.0.0.c3addon 10 kB
    11 hours ago
Download Primitives for Construct 3
Leave a comment