New DOM Side Plugin


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.

image.png

Inside your loaded script, you have full DOM APIs.

image.png

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.

You can listen to events like: image.png

And on the other side, you can dispatch them like: image.png

You can also do everything in EventSheets of course: image.png

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.

You can register a procedure like: image.png

Or you can do it via EventSheets: image.png

Then you can call those procedures from the other side like: image.png

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
6 hours ago
MasterPose_Vector-1.0.2.0.c3addon 10 kB
6 hours ago
MasterPose_Collider-1.0.2.0.c3addon 5.5 kB
6 hours ago
MasterPose_DomSide-1.0.0.0.c3addon 10 kB
6 hours ago

Get Primitives for Construct 3

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.