Construct 3 plugin SDK v1

For discussion and help with the Construct 3 Plugin SDK

Post » Tue Nov 28, 2017 5:30 am

locohost wrote:Looks like everyone, including me starts out trying to build C3 addons in the same sequence in which the manual reads. This is definitely NOT the way to start C3 addon development. The C3 SDK manual is upside-down. You MUST first setup a local plugin server, go through the process of getting that working. Then you MUST develop your plugins in "developer mode" per the manual. After you get your plugin loading and working in developer mode, you can say "it's working" and then do the normal .zip/.c3addon import into C3. DO NOT keep trying to import any custom plugin with even one single bug! In addition to no debugging info in the console, you will also lock up C3 editor addon mamanger and object import dialogs. Sometimes you will lock the main addon loading screen.

Get your local plugin dev server working FIRST and dev that way.

Here is my working C3 plugin server. If you don't know Node/Express, Google and you'll find a million articles and tutorials. Very easy to install. Below is a link to the zip of the c3-plugin-server app folder. Make sure you run your command window as admin. Unzip the app. Then run npm install to update/install all the packages you need. There are helpful comments in server.js. nodemon server.js will start the plugin server. Node provides good error messages on install. If you see any you should be able to fix.

https://drive.google.com/file/d/0B2LbtzyJ6MqNWHZnVDhfR2o1SFk/view?usp=sharing

Code: Select all
const https = require('https');
const fs = require('fs');
const path = require('path');
const express = require('express');
const cors = require('cors');

const corsOptions = {
   origin: 'https://editor.construct.net'
};

// You will need to use openssl or some Windows app
// to generate your own self-signed cert files. C3
// developer mode plugin loading will NOT work in Http
// mode. Plugin server must be Https
const serverOptions = {
   key: fs.readFileSync('./key-20171101-071835.pem'),
   cert: fs.readFileSync('./cert-20171101-071835.crt'),
   requestCert: false,
   rejectUnauthorized: true
};

const app = express();
app.use(cors(corsOptions));
// Put testing and non-plugin static content in this folder
app.use('/static', express.static(path.join(__dirname, 'static')));

// Put all plugin related code and static content in this folder
// Put each plugin in its own folder like: /plugin/mytestplugin1/
// In C3 addon manager, in developer mode, load plugin like...
//      https://localhost:49200/plugin/mytestplugin1/addon.json
app.use('/plugin', express.static(path.join(__dirname, 'plugin')));

const port = process.env.PORT || 49200;
https.createServer(serverOptions, app).listen(port, function () {
   console.log('Construct 3 plugin server running. Listening on port: ' + port);
});


@locohost

Thanks for this, I'm trying it out with nodemon server.js, but I am getting errors when trying to load the addon. It looks like the server is running (I can get the addon.json file via a general chrome browser request via: https://localhost:49200/plugin/example/addon.json ). I installed self-signed cert/key and updated server.js (otherwise the previous would not work.)

C3 reports the generic, 'unable to load, go check server, etc.'. Checking the chrome console, this is the error:

Code: Select all
r69-2/main.js:154 Error loading addon JSON:  TypeError: Assignment to constant variable.
    at d.ǃvcY (r69-2/main.js:73)
    at <anonymous>
ǃG.ǃEA.then.then.catch @ r69-2/main.js:154


If I put in another bad filename, I see a different error message on console, so I think the file is being server to C3. but then something seems to fail on parsing (I also tried the C3 EffectSDK example and get the same error.)

Any hints?
B
63
S
28
G
19
Posts: 186
Reputation: 14,584

Post » Tue Nov 28, 2017 11:56 am

Looks like this bug, should be fixed in r70.
Scirra Founder
B
415
S
247
G
92
Posts: 25,284
Reputation: 200,852

Post » Tue Nov 28, 2017 1:24 pm

Mikal wrote:Any hints?


@Mikal

No not really. It's a bug in your plugin (or the actual SDK code maybe?) code in main.js on line 73. Some const var is getting (attempting to be) set to a new value.

I'd recommend using the sample addon provided in C3 docs and get that fully working locally. Then you know you're setup 100% and ready to work :-)
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Tue Nov 28, 2017 2:13 pm

Thanks @locohost and @ashley. I'll wait for r70.
B
63
S
28
G
19
Posts: 186
Reputation: 14,584

Post » Tue Nov 28, 2017 2:17 pm

Mikal wrote:Thanks @locohost and @ashley. I'll wait for r70.


Sorry I wasn't more helpful :(
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Tue Nov 28, 2017 4:38 pm

locohost wrote:
Mikal wrote:Thanks @locohost and @ashley. I'll wait for r70.


Sorry I wasn't more helpful :(


No worries @locohost , it ended up being the bug Ashley mentioned (the same setup worked with the newer r70.2). Your pointer to node.js, and your server.js were very helpful to get everything up and running. What plugins are you working on?

As an aside, in my experimenting, I also got this working using node.js

(install via npm install http-server)

In dev plugin dir run:
Code: Select all
http-server -S --cors="Access-Control-Allow-Origin: *"


However, it's not as good as your setup, I think it only handles static files, so you need to restart it after you change the addon source files, while you setup handles it dynamically, so I'm going to stick with your setup.

Also an easy source for self-signed certs is: http://www.selfsignedcertificate.com/ I would not trust this for other uses, but I'm ok with it on my local PC.
B
63
S
28
G
19
Posts: 186
Reputation: 14,584

Post » Tue Nov 28, 2017 5:39 pm

That selfsignedcert link is good! That's waaaay easier that what I did. Thanks for sharing :-)
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Wed Jan 24, 2018 7:14 pm

justifun wrote:@lucid - behaviors were added recently, but drawing related stuff is still not implemented yet. (forum post here: behaviors-now-supported-in-sdk_t191739)

@martdsam - Here is a big list of addons for C2 : c2-plugins-and-behaviors-list_t65170

If i remember reading correctly somewhere, I believe there's a plan to keep a better repository within addon manager for C3 down the road, integrated directly in it.

but for now i've been hosting a constrct 3 compatible addon list here: c2-plugins-and-behaviors-list_t65170

with the ability to submit new links here: https://docs.google.com/forms/d/e/1FAIp ... g/viewform


Hi @justifun the link to construct 3 plugins list is actually list of c2 plugins
B
20
S
5
Posts: 48
Reputation: 1,362

Post » Tue Mar 27, 2018 9:33 pm

It would be really helpful to have a data type for plain JavaScript object.

On my plugin (Colyseus) I'm using the "variadic" type to allow multiple options, but my scenario it would be ideal to have multiple options with custom names. (like x=1, y=2, z=3)

I had to parse the data later, and the usage is not intuitive. The user should then enter the name of the option, "=", and the value. Using strings.

Image

Are there any plans to support more data types? Cheers!
B
7
S
2
Posts: 9
Reputation: 489

Previous

Return to Plugin SDK

Who is online

Users browsing this forum: No registered users and 0 guests