Javascript Plugin and Behavior SDK documentation

Forum Home Forum Home > Construct 2 General > Construct 2 general
 Post Reply Post Reply Page  123>
Author

Scirra Developer
78,503 Rep
Post Options Post Options   Quote Ashley Quote  Post ReplyReply Direct Link To This Post Topic: Javascript Plugin and Behavior SDK documentation
    Posted: 14 Aug 2011 at 11:22pm
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!

Edited by Ashley - 01 Dec 2011 at 12:47am
Back to Top

Scirra Developer
78,503 Rep
Post Options Post Options   Quote Ashley Quote  Post ReplyReply Direct Link To This Post Posted: 15 Aug 2011 at 12:13am
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.
Back to Top

Moderator
28,650 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 15 Aug 2011 at 1:13am
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.
Back to Top
1,437 Rep
Post Options Post Options   Quote Mehtab Quote  Post ReplyReply Direct Link To This Post Posted: 15 Aug 2011 at 11:46am
i was waiting for this!
Back to Top
5,964 Rep
Post Options Post Options   Quote cow_trix Quote  Post ReplyReply Direct Link To This Post Posted: 15 Aug 2011 at 2:44pm
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.
www.lrtw.net
Back to Top

Moderator
28,650 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 15 Aug 2011 at 3:00pm
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:
"id": "loL",

runtime:
/////////////////////////////////////
// Plugin class
cr.plugins.loL = function(runtime)
{
     this.runtime = runtime;
};

(function ()
{
     var pluginProto = cr.plugins.loL.prototype;
Back to Top

Scirra Developer
78,503 Rep
Post Options Post Options   Quote Ashley Quote  Post ReplyReply Direct Link To This Post Posted: 15 Aug 2011 at 4:01pm
Originally posted by cow_trix cow_trix wrote:

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.

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.
Back to Top

Scirra Developer
78,503 Rep
Post Options Post Options   Quote Ashley Quote  Post ReplyReply Direct Link To This Post Posted: 17 Aug 2011 at 6:14pm
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.
Back to Top
1,172 Rep
Post Options Post Options   Quote I7redd Quote  Post ReplyReply Direct Link To This Post Posted: 17 Aug 2011 at 9:25pm
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>]
Back to Top

Moderator
28,650 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 17 Aug 2011 at 10:32pm
Thank you Ashley, this is very helpful.
Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down