System Expressions in Javascript

0 favourites
  • 4 posts
From the Asset Store
Add this awesome sound effects to make your visual novel come to life!
  • What is the preferred way to invoke system expressions in scripting api?

    Should we create a function that returns the value of the system expression? and just execute runtime.callFunction ?

    I see some system expressions are implemented as part of C3 obj? such as

    C3.angleTo(), C3.distanceTo(), C3.toDegrees() and a few other ones, but these don't seem to be documented so I am not sure if it's frowned upon using them. and they also don't encompass most of the actions

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The scripting reference covers what you can access directly from JavaScript, e.g. IRuntime. Some system expressions already have equivalents, which may be on different interfaces (e.g. how the layout width and height is part of ILayout), rather than in one big list, as is appropriate for a JavaScript API. Others are straightforward to implement with built-in JavaScript features or your own small functions. Some others may not be supported yet. So the answer depends on the specific system expressions you intend to use.

  • My question is more geared to C3.angleTo/C3.distanceTo/C3.toDegrees .. and all the other utility functions on the C3 object, since those are not prefixed with an _, is it safe to use those or should we create our own? They are not part of the official documentation? so I was just curious what the guidance is on those functions?

  • As stated in the documentation, do not use any undocumented features. I can't stress this enough - it's a really terrible thing for support and compatibility which pretty much always ends in disaster for everybody, but it still seems to be hard to keep getting this message across. Undocumented features are not guaranteed to keep working as they are internal details of the engine and are subject to change at any time. If you use them, your code could break at any time and we won't offer support if that happens either. The official documentation also stresses this, which also points out:

    The only reason these can be found is because the way JavaScript works makes it difficult to hide them.

    Just make your own, especially as these functions are really simple. For example distanceTo is just Math.hypot(x2 - x1, y2 - y1), angleTo is just Math.atan2(y2 - y1, x2 - x1), toDegrees is x * 180 / Math.PI... I'm sure you can find many more equivalents with a quick web search.

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