I want my construct game to fire a 'level ready' event or function, and I want my external JS app to be able to receieve that event.
I also want my external app to fire a 'play level' event or function, which construct can receive.
Ideally i'd also like to be able to check if construct is in preview mode (IsPreview()??), or if it's running on the live server
I found this in the docs, but honestly I find the scripting section of the documentation really confusing when it comes to actually applying it. Think it could do with some more in-line examples imo.
The runtime side can issue DOM calls using a specially-designed messaging API built in to the runtime. Essentially instead of making a call, you simply post a message with parameters for the call to the script on the DOM side, where the API call is really made. The DOM side can then send a message back with a result, or send messages to the runtime on its own, such as in response to events. The messaging APIs make this relatively straightforward.