Return Project Version in Plugin?

For developers using the Construct 2 Javascript SDK

Post » Sun Oct 27, 2013 1:28 am

Hi all,

Just wondering the best way to retrieve the project version from a plugin. Essentially the same value as the projectversion expression.

Cheers
Moderator
B
72
S
14
G
11
Posts: 900
Reputation: 11,920

Post » Sun Oct 27, 2013 12:41 pm

I think you can access it via this.runtime.versionstr.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Sun Oct 27, 2013 12:52 pm

@Ashley I've tried this, but it always returns undefined. I have no problem with any other this.runtime.* variables. I can even see it in the inspector, very confusing.
Moderator
B
72
S
14
G
11
Posts: 900
Reputation: 11,920

Post » Sun Oct 27, 2013 2:40 pm

Which function are you trying to access it from? If you're in a closure or global function you'll need another way to get the runtime variable.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Sun Oct 27, 2013 2:48 pm

@Ashley this is from instanceProto.onCreate.

This returns undefined:

[CODE]
instanceProto.onCreate = function()
{
console.log(this.runtime.versionstr);
}
[/CODE]
Whereas this returns false as expected:
[CODE]
instanceProto.onCreate = function()
{
console.log(this.runtime.uses_background_blending);
}
[/CODE]
Any other this.runtime.* variables I've tried also work. I can't work out why versionstr is returning undefined, even though I can clearly see it as defined when doing console.log(this.runtime).
Moderator
B
72
S
14
G
11
Posts: 900
Reputation: 11,920


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests