Calling external javascript from webworker / runtime messaging API in webworker

0 favourites
  • 2 posts
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You linked to the addon SDK documentation, which does not apply to the scripting feature of Construct. That's documented in the scripting section of the Construct manual.

    You can test for preview mode by seeing if the location's origin is

    If worker mode is a problem, the easiest thing to do is turn it off. In recent releases of Construct, it defaults to a new "Auto" mode that automatically turns it off if you use any scripts.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)