Script Editing and the Viewing of Code

Get help using Construct 2

Post » Wed Nov 16, 2011 9:17 am

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...
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Wed Nov 16, 2011 10:25 am

+1 for both from me
B
33
S
7
G
6
Posts: 34
Reputation: 4,815

Post » Wed Nov 16, 2011 10:36 am

[QUOTE=brent_hamel]I often find that the majority of my bugs are occuring within the embedding of events and not the events themselves[/QUOTE]

Most of code behind the event is in plugin/behavior. At folder \exporters\html5\plugins (or behaviors)rexrainbow2011-11-16 10:46:19
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Wed Nov 16, 2011 10:47 am

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?
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Wed Nov 16, 2011 12:38 pm

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.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Wed Nov 16, 2011 1:19 pm

When you say code, what exactly are you expecting to see?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Nov 16, 2011 1:53 pm

[QUOTE=Noga] 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.[/QUOTE]

Yeah, CC Debug is a great feature! It's aimed at more advanced users, but a great help as projects become more complex.
B
107
S
40
G
10
Posts: 456
Reputation: 13,202

Post » Wed Nov 16, 2011 2:30 pm

[QUOTE=newt] When you say code, what exactly are you expecting to see?
[/QUOTE]
For me it's the HTML5 code to see how it was put together.
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Wed Nov 16, 2011 4:02 pm

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):

[code]"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"]]
                         ]][/code]

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.Ashley2011-11-16 16:02:59
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Nov 16, 2011 4:52 pm

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.brent_hamel2011-11-16 16:53:00
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go and 21 guests