A proposal for Javascript scripting in Construct 3

You're viewing a single comment in a conversation. View all the comments
  • 26 Comments

  • Order by
    • [-] [+]
    • 1
    • Ashley's avatar
    • Ashley
    • Construct Team Founder
    • 1 points
    • (25 children)

    How does attaching a script to an object change how it's run or change what kind of code you can use? This doesn't appear to have been explained, and there is nothing like it in the JavaScript language itself. I'm pretty wary about diverging too far from how JavaScript normally works, because one of our key goals is to help people learn skills they can re-use elsewhere.

    • It doesnt change how it's run at all because the script is only a class getting defined. What it would do however would be to link an instance of that class to said object.

      If code were to be put outside the class it would just run on startup like any other script. The script also only needs to be ran once to define the class and not on every object it's linked to. It's really just replacing the need to write the one line of JS in event I wrote

      instance.Rotate = new Rotate(instance, data, runtime)

        • [-] [+]
        • 2
        • Ashley's avatar
        • Ashley
        • Construct Team Founder
        • 2 points
        • (23 children)

        Ah, I think this can be done with subclassing. No need for separate scripts for that.

        • What do you mean?

            • [-] [+]
            • 2
            • Ashley's avatar
            • Ashley
            • Construct Team Founder
            • 2 points
            • (21 children)

            It's a way of using your own custom class deriving from WorldInstance. So you can add all your own custom properties and functions, and still do everything WorldInstance does.

              • [-] [+]
              • 2
              • skymen's avatar
              • skymen
              • Affiliate
              • 2 points
              • *
              • (20 children)

              That's interesting, how would it work exactly?

              Is it already possible in r151?

              Edit: nvm I just got what you meant. But that's already what I kinda do in the article, except I don't have access to the WorldInstance class so I made my own and get WorldInstance later. I didn't mean to make it possible, I meant to make it integrated in the editor and have a better workflow for it