Please add more templates and tutorials on scripting

  • Ashley, Nepeo - first of all, thank you for this great feature!

    As I understand, the main idea of scripting is to extend events, not replace them. Unfortunately, there is currently only one template (Ghost Shooter), and it doesn't provide much information on using scripting in combination with event sheets.

    So could you please add more templates/tutorials for people like me not very experienced with JavaScript, demonstrating how to use scripts integrated with events. Particularly:

    • When object instances are picked by event, how to pick same instances in the script. For example, I have an event "Player has LOS to Enemy", inside it a JS function "MarkEnemies()" is called, will it automatically pick the same enemy instances as the parent event?
    • Different ways to pass information from the script back to events - set global/local variables, call C3 functions etc.
    • How to use object's triggers, conditions and run actions from the script? For example, if I need to change Bullet angle, I should call something like Player.Bullet.SetAngleOfMotion(n) - what is the correct syntax and where can I find this action/method name?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I currently have 2 games that demonstrate how to mix events and java script, they are not really tutorials but going through might help a bit. you can get the c3p files here

    https://www.patreon.com/posts/tank-trax-clone-28597133

    https://www.patreon.com/posts/word-finder-28761484

    with that said It would be nice to see some more official templates integrating the scripting feature

  • Awesome, thank you!

  • When object instances are picked by event, how to pick same instances in the script. For example, I have an event "Player has LOS to Enemy", inside it a JS function "MarkEnemies()" is called, will it automatically pick the same enemy instances as the parent event?

    Scripting has no concept of picking. That whole concept is unique to Construct's event system. However you can access the picked instances from script using the IObjectClass methods, e.g. the pickedInstances() iterator.

    Different ways to pass information from the script back to events - set global/local variables, call C3 functions etc.

    That's already covered by the Integrating events with script example.

    How to use object's triggers, conditions and run actions from the script? For example, if I need to change Bullet angle, I should call something like Player.Bullet.SetAngleOfMotion(n) - what is the correct syntax and where can I find this action/method name?

    All available calls are documented in the scripting reference section of the manual. However behavior calls aren't yet supported - it's on the todo list.

  • Thanks, Ashley. I've studied the documentation. But as I said, as someone who is not very experienced with Javascript and has little understanding of how Construct 3 works internally, I still struggle trying to write my own scripts.

    It would help beginners a lot if you could maybe add more code snippets to the documentation, or create a few more templates/tutorials.

    All available calls are documented in the scripting reference section of the manual. However behavior calls aren't yet supported - it's on the todo list.

    What about object's conditions and actions? For example, "Sprite Is overlapping another object" or "Dictionary set key" - how do I call these from the script?

  • What about object's conditions and actions? For example, "Sprite Is overlapping another object" or "Dictionary set key" - how do I call these from the script?

    There isn't any way to call arbitrary conditions/actions/expressions, and probably won't be, because as I mentioned these fundamentally rely on picking which isn't a concept in scripting. There are alternatives though, such as the method to test for an overlap between two instances, or script interfaces to access specific features like dictionary keys. These are the kinds of building blocks that the Construct engine itself is built from, and these are the same things you can use in scripting to build your game out of as well.

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