Process Event Sheet from Javascript

0 favourites
  • 9 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Sorry if this question has been answered before, but I couldn't find anything after reviewing the docs and forum posts:

    How does one go about calling an Event Sheet from within JavaScript? For example

    	
    async function OnBeforeProjectStart(runtime)
    {
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function Tick(runtime)
    {
     // Call Tick on Event Sheet "my_cool_event_sheet"
    }
    

    The idea is event sheets could be really cool to prototype something before I invest the time to write up a more complex bit of logic in Javascript. Similar to the Unreal Engine where I can invoke a Blueprint from C++.

  • I don't think there's any reason to call an entire event sheet. Instead use runtime.callFunction() to call a function block in an event sheet.

  • Sorry I didn't really describe my use case very well and maybe some of this is just confusion on my part. Let me take another swing at this:

    I create a new JavaScript project because I have a back end server using WebSockets that needs to process incoming/outgoing network events, stream down server generated assets, etc.

    However when I create a new event sheet in my project it doesn't seem to be picking up things like keyboard input or basic tick handlers. Additionally I would like to process some things before the sheets tick event are processed and then other actions/operations after all the sheets have been "ticked".

    Is this possible and if so is there any examples of such a use case implemented I can review?

    Thank you so much for your help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make sure a layout in the project has the event sheet associated. If you have no event sheets and you add one, it won't be associated with anything so those events won't run until to attach it to a layout.

    You can call in to events from JavaScript and from JavaScript to events, so you should be able to set up everything you need using both.

  • I see and yes that was the issue. So follow up question:

    Is it possible to set the event sheet for a Layout via JavaScript? I looked in the APIs and didn't any direct calls for such an action.

    Example:

     // Does not seem to exist
    	runtime.layout.setEventSheet("My_cool_sheet")
    

    For example I might want to swap out event sheets based if a socket is still connected, etc.

    Thanks for all so much your help!

  • I don't think there's any reason to do that. You can just include all the event sheets you might need, and enable or disable groups.

  • I think it is more like if this is even an option. Is there an API to enable such functionality?

    Thanks!

  • Just wanted to poke this thread to see if there was any follow up to if there is an API that can enable such functionality.

    Assuming the answer is: No this is not currently possible in Construct.

    What is the process to make a feature request for something. I can see this being very helpful in a AI style behavior processor where I would like to build small "event sheets" and dynamically swap them out on the fly based on the some server state, etc. As compared to having one very large sheet that covers all possible cases.

    Thanks!

  • There doesn't seem to be any reason to do this. So it's not supported. As I said you should be able to already do the same kind of thing enabling and disabling groups.

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