Script Editing and the Viewing of Code

0 favourites
  • 15 posts
From the Asset Store
Here is the wonderful & amazing script for your website or fun with maths.
  • Sorry if this is in the wrong place, I wasn't exactly sure where to post this. I remember not long ago that Ashley mentioned wanting input on smaller, more user-friendly tweaks and ideas, to aid with the usability of Construct 2. So with that in mind (these are somewhat bigger and possibly impossible to implement, I don't know...)

    1. a script editor, now I didn't know enough about python to play with this in Construct Classic, but it sure would be a useful feature in Construct 2 (don't know if this is already planned or not)

    2. a way to toggle between the visual event sheet and the actual code it's representing, I often find that the majority of my bugs are occuring within the embedding of events and not the events themselves, being able to actually see the code once in a while might help with this as it would read in a more straightforward way for geeks like me that come from a code based background. (don't know if this is even possible, would depend entirely in how Construct 2 is working behind the scenes)

    I suppose those weren't small ideas after all, but they feel important to me. Given that the actual conditions available are still somewhat limited, it would be extremely useful to have a means to simply write a script, and because the naming conventions and embedding hierarchy can be a little confusing at times, being able to toggle a "Code Mode" would be incredibly useful in understanding just what Construct 2 is referencing and doing, if a "Code Mode" is even possible to do that is...

  • +1 for both from me

  • I often find that the majority of my bugs are occuring within the embedding of events and not the events themselves

    Most of code behind the event is in plugin/behavior. At folder \exporters\html5\plugins (or behaviors)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I highly doubt there will be a script editor as C2 is event driven but

    I would definitely like to see the code behind the events, may be a code viewing window?

  • Debugging like in CC would be great help, I think it's on the todo list, don't know how difficult it is to implement, though.

  • When you say code, what exactly are you expecting to see?

  • Debugging like in CC would be great help, I think it's on the todo list, don't know how difficult it is to implement, though.

    Yeah, CC Debug is a great feature! It's aimed at more advanced users, but a great help as projects become more complex.

  • When you say code, what exactly are you expecting to see?

    For me it's the HTML5 code to see how it was put together.

  • For #1: we don't want to do a script editor in the foreseeable future for two reasons - firstly, for HTML5 it would be snippets of Javascript, so suppose everyone uses snippets of javascript in all their games. If we made a different exporter that doesn't use javascript as a programming language, it becomes impossible to export all those games using code snippets to the new exporter, so it would make it impossible to use the new exporter for existing games. Secondly, scripting is a programming thing, and our focus is currently on the non-programming aspect.

    For #2: this is a common misconception. There is no code to look at. Construct 2 does not generate code for events - it generates a data model that is then interpreted. So you can look at what Construct 2 generates for events, but it's just a big block of data. Here's a small snippet of what Space Blaster's looks like without minification enabled (which deliberately makes the code unreadable):

    "Game events", [
         [
         1, "Score", 0, 0],
         [
         1, "Rockets", 0, 3],
         [
         0, [true, "Player and general"],
              [
                  ?[-1, cr.system_object.prototype.cnds.IsGroupActive,
                  ?null, false, false, false, false, [
                        [
                        1, [
                        2, "Player and general"]]
                  ?]]
              ],
              [],
              [
                  ?[
                  ?0, null, [
                        [-1, cr.system_object.prototype.cnds.OnLayoutStart,
                        null, true, false, false, false]
                  ?],
                        [
                             [
                             11, cr.plugins_.Sprite.prototype.acts.Destroy, null],
                             [
                             31, cr.plugins_.Audio.prototype.acts.Play, null, [
                                ??[
                                ??2, ["squaremotif1", false]],
                                ??[
                                ??1, [
                                ??2, ""]]
                             ]],
                             [-1, cr.system_object.prototype.acts.Wait, null, [
                                ??[
                                ??0, [
                                ??1, 1]]
                             ]],
                             [
                             31, cr.plugins_.Audio.prototype.acts.Play, null, [
                                ??[
                                ??2, ["mattoglseby - 3", true]],
                                ??[
                                ??1, [
                                ??2, "music"]]
                             ]]

    So I'm not sure you really want to do anything with that. From there C2 does call actual javascript functions which each plugin defines (@rexrainbow was describing this) but those are the code "inside" each condition and action and expression. If you like you can use Chrome's debugger and set breakpoints in these functions, but I still don't think there's much to gain from it - it tells you more about how each function works than what your events are doing overall.

  • Thanks for all the info guys!

    I sort of figured there wouldn't be a way to view code, again the main reason I was interested is to gain a clearer understanding of every condition/action and specifically what they're doing behind the scenes, so perhaps some simple documentation or perhaps more in depth descriptions in their respective selection windows is all that's needed.

    I understand now why scripting isn't going to be included, it is a shame there's no efficient way of including it :( the ability to create custom code is so flexible and useful.

    And any frustration I experience with Construct 2 comes from sheer excitement at the potential it's already displaying as well as the potential it will possess in the future.

  • I forgot to mention, you can code your own javascript in the plugin and behavior SDK, but it's not really suitable for casual coding, more for integrating APIs and creating new features.

    If you're interested in how it works under the hood, you can still browse the javascript code behind the plugins and behaviors, they're all in the folder rexrainbow mentioned.

  • I just wish to add to Ashley's excellent answer that if you feel like coding in the end you can always make your owns plugins and behaviors thanks to C2's SDK.

    It's pretty straight-forward, a lot of fun, it can be useful depending on your project but be aware that if there was another exporter made for C2, you would then have to make a plugin for this exporter too before exporting the game with it. (oops, Ashley ninja'd :/ )

    And finaly for those wanting some debugging, you can always create a condition "In preview" and display some values from there for your debugging needs. It would require a text or a browser object and the alert action, but it's often useful.

    so perhaps some simple documentation or perhaps more in depth descriptions in their respective selection windows is all that's needed.

    Do you mean like the inline documentation in codition/actions/expressions window ?

    Also the manual is soon coming, it takes time to write.

  • Either/or, it's mostly just my eagerness getting the better of me lol, reading the SDK information makes me want to build a visual array editor... that could also load from a txt file... hmmm...

  • build a visual array editor... that could also load from a txt file... hmmm...

    CSV plugin could help you do this.

    There already has many plugins, and welcome to the plugins' world!

  • ok, just downloaded every dang plugin and behaviour in that list lol gotta be honest though, about 1 third of them I have NO clue what they do lol

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