Javascript Plugin and Behavior SDK documentation

Discussion and feedback on Construct 2

Post » Sun Aug 14, 2011 11:22 pm

This thread is being retired since the SDK is now hosted in the Manual section of the site. Click here to visit the online SDK documentation.

Old thread is below for archiving's sake. This post content is now out of date - the above link is now the latest version of the SDK documentation.
===================
Plugins and behaviors can be written for Construct 2 in Javascript. Since there's been some plugin work already - and I myself keep forgetting how it works - I've been writing up some documentation for the SDK.

HTML5 Javascript SDK and documentation

Also, user Kyatric has kindly compiled a HTML version of the SDK documentation viewable online.

Last update: 28th November 2011

This is currently some very lo-fi text files, but the content is there. There are also templates to help get you started with a plugin or behavior. In future, it'll all be hosted on the site, linked up, and so on.

Let me know if you have any problems, find anything confusing, or get stuck - we're more than happy to help!Ashley2011-12-01 00:47:17
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Mon Aug 15, 2011 12:13 am

Oh, just a heads up: there are some SDK changes in r51, and the docs are written as if those have already been made. Next build should be out soon then these docs are current.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Mon Aug 15, 2011 1:13 am

Thank you Ashley. Hopefully more devs will look into making plugins and behaviors for C2.

I have a suggestion here, adding a "version" field to the plugin settings. This might help for future iterations over existing plugins.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Aug 15, 2011 11:46 am

i was waiting for this!
B
12
S
5
G
5
Posts: 80
Reputation: 3,572

Post » Mon Aug 15, 2011 2:44 pm

Hey Ash, when I try and compile I get told that my Plugin ID is missing. But I defined it in the runtime.js
Any thoughts?
Also, is there any way to directly inject JS through a plugin? As in the user defines a JS script to be executed as an event.
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Mon Aug 15, 2011 3:00 pm

If you have incorrect javacript (syntax error probably) in your plugin's code, you might get the plugin ID error.
Be sure to go through The MDN guide for javascript. The basics can be learnt in a couple of days if not less.

Also be sure that the string defined in "id" field in edittime.js is the same when defining the plugin class.

Example:
edittime:
[code] "id": "loL",[/code]
runtime:
[code]/////////////////////////////////////
// Plugin class
cr.plugins.loL = function(runtime)
{
     this.runtime = runtime;
};

(function ()
{
     var pluginProto = cr.plugins.loL.prototype;
[/code]
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Aug 15, 2011 4:01 pm

[QUOTE=cow_trix]Also, is there any way to directly inject JS through a plugin? As in the user defines a JS script to be executed as an event.[/QUOTE]
Yes, through the eval() function, but if done incorrectly this can open up security vulnerabilities, and might not survive the minifier. So I don't think you should do this.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Wed Aug 17, 2011 6:14 pm

Updated the original link - the docs now include the runtime side. This should cover just about everything for now! When the site has a manual section I'll port all the content over so it's a bit more readable. All the content is there right now though.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Wed Aug 17, 2011 9:25 pm

Choice timing!

Hey Ashley, just wanted to join the chorus of appreciation for making such an inspiring piece of software, and including your diligence on all matters for building such a cool community around it. Really well done. [=D>]
B
6
S
1
G
2
Posts: 32
Reputation: 1,347

Post » Wed Aug 17, 2011 10:32 pm

Thank you Ashley, this is very helpful.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests