Is it possible to call Layout or other system actions from javascript?

0 favourites
  • 4 posts
From the Asset Store
Medeival & Viking War Horns Sounds / 22 Unique Calls / 2:40 minutes of audio
  • We are working on some games and would like to share some common behaviors across them using a Javascript library we will be build. This will have some helpers to consolidate sound and scoring behaviors which we can handle by passing the runtime in from event sheets.

    One requirement we have though is to update the game state from that javascript code - examples would be changing the current Layout or calling Layout.Restart Layout

    I have looked through the documentation I can find around the javascript runtime but cannot see any references to how these higher order Construct actions can be invoked.

    Thanks!

  • See the scripting reference section in the manual for the currently available APIs you can use in scripting. This is being updated over time as the feature is relatively new and we're continuing to add new APIs. In the mean time if you need to run some actions from script which there aren't equivalent APIs for, use runtime.callFunction() to call an event which runs the actions you want.

  • Thanks for the info. It looks as though very little of the behavioral items are exposed - at least from what I see in the docs. Presumably using callFunction would require that we have that function defined on an event sheet - correct? That does limit portability or reusability from the Javascript side since we would have to copy a corresponding event sheet into each project. Not the end of the world.

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • andrewrutter Behaviour interfaces are still very new, I don't think they have made it to the manual yet. There is a small amount of information about them in the r167 release notes. As it says it only supports the bullet behaviour at the moment, but we will be adding more interfaces in future.

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