A proposal for Javascript scripting in Construct 3

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

  • Order by
  • I totally agree with you on that point. We'd need to see people actually write JS code and hundreds of lines before being sure of anything.

    Well it'd be hard for the editor to get more in the way than "used for everything on layouts and basically anything that is not immediately code"

    One example of how the editor could be useful would be:

    Instead of doing

    runOnStartup(async runtime =>

    {

    runtime.objects.Player.setInstanceClass(PlayerInstance);

    runtime.setEventListener("tick", PlayerInstance.Tick)

    }

    Just add a button on the object properties tab and add the PlayerInstance class script to it.

    Same button could be used to generate a new script file that would automatically write the basis for a subclass from the right class instead of having to guess or look at the docs.

    Having to write the code somewhere else would indeed be counterproductive

      • [-] [+]
      • 1
      • Ashley's avatar
      • Ashley
      • Construct Team Founder
      • 1 points
      • (1 child)

      So this either means writing your script somewhere else, which as you note is counterproductive, or just filling in code templates for you.

      Is that all you're asking for then? Filling in code templates?

      (That's actually pretty difficult because e.g. finding the right place to add setInstanceClass() in runOnStartup() without making a mess of your code is tricky - or if you have multiple runOnStartup() calls which one do you pick, etc. etc.)

      • Filling in code templates would work yeah.

        In that regard, you could just fill in a hidden template for the runOnStartup to avoid the trouble of having to chose the right function, and to avoid the case where the user messes with it.

        But yeah what I'm asking for is just quality of life stuff, and a set of conventions, far from a rewrite of the engine.

        Though one thing that does bug me is that if we do have a way to "add a script to an object through the editor" it would be nice to be able to add multiple ones and that does require a bit more work.

        I wanna try writing what I mean into JS and send the file to you as I'm sure it would be much clearer.