Can you include new scripts with the edittime?

For developers using the Construct 2 Javascript SDK

Post » Fri Aug 03, 2012 6:55 am

Is there a way to include a javascript(s) in the edittime.js without it getting used for the runtime.js also and then built into the exported project like the common.js does.

I did try the regular JS ways to include other files but i get errors which i think must be because it is using V8 for edittime. Basically i would like to have some common functions in a separate javascript but use it only with the edittime rather than getting it included.

Maybe there is a way to do this or change the common.js settings to only include with either the edittime or runtime?

If this is not possible i would like to request this as it would be very useful to me, many thanks.
B
9
S
3
G
4
Posts: 55
Reputation: 2,607

Post » Fri Aug 03, 2012 10:34 am

@FireLight

1) If you only want to include the code in edittime.js and not in runtime.js, why can you not simply code it directly into edittime.js itself?

2) What exactly are you wanting to include in your edittime.js?

3) Why do you call them "common functions"? What are they common to? (common.js is necessarily common to both edittime.js and runtime.js - that's what 'common' means, but what does it mean for you?)
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Fri Aug 03, 2012 12:04 pm

Most javascript libraries (e.g. jQuery) assume they are being used in a browser. Construct 2's edittime script is a pure V8 context with no browser, which means very very few Javascript libraries will work in it. Which library are you considering?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Aug 03, 2012 12:18 pm

[QUOTE=Velojet] @FireLight
1) If you only want to include the code in edittime.js and not in runtime.js, why can you not simply code it directly into edittime.js itself?

2) What exactly are you wanting to include in your edittime.js?

3) Why do you call them "common functions"? What are they common to? (common.js is necessarily common to both edittime.js and runtime.js - that's what 'common' means, but what does it mean for you?)[/QUOTE]

1) Because i want it organized and like to use multiple scripts, it makes things much easier to organize and update projects that way.

Also as i said the common.js already offers this and it would otherwise be perfect for my needs however it has the problem i posted above in that it adds all the extra code to the exported project. Why would one want to use common.js and add to the exported projects file size when that shouldn't be needed on the edittime side though?

2) Various things depending on the plugins, everything from simple value limiting and variable storage to graphical things like drawing GUI controls.

Sure i could pack a load of code into a single file but then as the complexity grows the project gets messy, no doubt that is why scirra's own framework is split into multiple parts rather than in one huge js file. Basically i like organized projects where i can quickly find things, if you could set ../ on the path you could also use it across multiple plugins.

3) I was not referring to the common.js script, by that i mean commonly used functions (a library of functions basically).

The bottom line here is however i read a post where the developers of this program asked what features plugin developers wanted to help make this the best game development tool, i need this feature so i though requesting it would be a good idea. FireLight2012-08-03 12:30:48
B
9
S
3
G
4
Posts: 55
Reputation: 2,607

Post » Fri Aug 03, 2012 12:22 pm

[QUOTE=Ashley] Most javascript libraries (e.g. jQuery) assume they are being used in a browser. Construct 2's edittime script is a pure V8 context with no browser, which means very very few Javascript libraries will work in it. Which library are you considering?[/QUOTE]

Thanks for your reply, I will be making my own library based around the current features doing various tasks i might need to use on the edittime.js side.

I was also planning on using some external things such as encryption etc so it just decrypts the strings on the runtime side. There would probably be other things i would do if this feature was available though, i mentioned a few other reasons why i think this would be a great option above before i read your post also.FireLight2012-08-03 12:27:47
B
9
S
3
G
4
Posts: 55
Reputation: 2,607

Post » Fri Aug 03, 2012 11:45 pm

@FireLight

Thanks for your explanation/clarification. You've butted up against one of the inherent limitations of JavaScript running in a non-browser environment viz. its lack of an import/include/require facility, like that enjoyed by C/Java/Perl/PHP ....

Until JavaScript adds this (or the Scirra team modifies their engine to provide for loading an edithelper.js, as for common.js), dropping in the source code itself would seem to be your only option
B
105
S
20
G
12
Posts: 549
Reputation: 20,320


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests