Any way of defining dependency of another plugin?

For developers using the Construct 2 Javascript SDK

Post » Tue Nov 04, 2014 11:19 pm

Hey all

I'm creating a plugin for smartfox server (online engine). Some events return JSON objects I want to transfer to C2, so I stringify it, and "hope" the client has Yann's JSON plugin or any other plugin that converts string to JSON.

Any way to force my plugin to check for a JSON dependency, or should I just leave it to the user's choice? If he tries to get "Smartfox.config" for example, he'll get a json string...

Thanks!
B
18
S
7
G
1
Posts: 157
Reputation: 1,928

Post » Wed Nov 05, 2014 12:18 am

Currently, there is no way to do this.
Another solution for your case is using a string expression which convert Json to string, passing this expression to yann.json object.
B
108
S
26
G
272
Posts: 4,472
Reputation: 152,279

Post » Wed Nov 05, 2014 7:24 am

If I understand you correctly, that's what I do now. I use JSON.stringify on the object, passing it to construct, and use yann's JSON to get the data I need.
Alternatively, I have some properties that return a specific property from the JSON.
B
18
S
7
G
1
Posts: 157
Reputation: 1,928

Post » Wed Nov 05, 2014 11:45 am

There is no way to do this because it's not a good idea. Allow the user to do what they want with the returned data, don't force them in to specific solutions.
Scirra Founder
B
398
S
236
G
88
Posts: 24,433
Reputation: 194,635


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests