this.runtime equivalent in Edittime

For developers using the Construct 2 Javascript SDK

Post » Wed Nov 23, 2016 10:47 am

Hi,
Is there an equivalent of this.runtime in Edittime, I'm trying to access other edittimes, It can be easily done in the runtime by adding childs to the this.runtime. which is shared by all the plugins.

But what about the edittime ?
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Wed Nov 23, 2016 11:56 am

No, it's pretty limited. Instances can only access themselves.
Here's all I've found to be available at edittime:
viewtopic.php?f=154&t=106202&p=786731&hilit=Edittime#p786731

I suppose you could make a global js variable and store references there. I think I've tried it one time, but I forget why it didn't work out.
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335

Post » Wed Nov 23, 2016 7:33 pm

@R0J0hound what about cr or renderer ? Tried with global var but it didn't work because they're only limited withing the plugin
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Wed Nov 23, 2016 9:32 pm

Either of those could be a spot to put a global value, but you may be better off making your own global variable. I think the edittime.js is put inside a closure so vars there aren't global as you say.

I fount this snippet online as a way to get the global namespace.
var global=Function("return this")();

After getting that you can add a global variable with:
global.myvar=1337;

Then using something like:
alert(myvar);
Should work in any other edittime.js after that.
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335

Post » Wed Nov 23, 2016 10:27 pm

@R0J0hound Unfortunately it didn't work. Is there a way to run JS libraries while on Edittime ?
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Wed Nov 23, 2016 11:06 pm

I got it working here. I set a global from one instance and was able to access it from another. Not sure if I can do anything too useful yet beyond that.

Uou can only run js you include in your edittime or common.js. It's basically just plain js and anything the editor provides.
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests