add two numbers in javascript?

Get help using Construct 2

Post » Tue Jul 23, 2013 2:45 pm

I need to call javascript to do some calculations which would not be feasible in C2. I've read the plugin docs, and looked through some plugins which draw stuff, but cant see how to return a value.

Could someone write a very simple plugin which say adds two numbers (passed to the plugin as parameters) and returns the result back the game?

This would make a great tutorial too (there is one for drawing a grid, which is good, but not relevant in this case).

Or is there another way to call a simple JS function without the complexity of plugins?
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Tue Jul 23, 2013 3:08 pm

It's not feasible, or not feasible for you?
Couldn't you just use Ajax to get the numbers?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jul 23, 2013 3:14 pm

Returning is documented here:
https://www.scirra.com/manual/24/ace-implementations
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Thu Apr 10, 2014 7:30 am

Hello, We are considering using construct 2. I was looking at SDK documentation. I haven't tried making a plugin yet.
I was hoping I could check something with you.

It is important for us that the data flows between game and javascript has a rich interface - meaning I should be able to pass lists or vectors etc.

Looking at the link above,
It appears javascript function can only return scalar values to the game .

Looking at the demo typer.capx ,
It seems game can only pass scalar parameters to javascript functions. Is such things were possible it would be good to change typer.capx to return values.

It looks like the Plugin SDK is the way to go. Can I return a vector datastructures from Javascript? - Like a list of strings/floats, a dictionary etc preferably heteregoneous. And can I pass such datastructures from game to javascript?

Thanks
B
3
Posts: 2
Reputation: 179

Post » Thu Apr 10, 2014 7:35 am

You can only pass strings/float/integer between Plugins and Construct 2.
But since JSON exists, this shouldnt be a problem :)
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Apr 14, 2014 3:02 pm

Hello Vuuv, Thank you.
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 6 guests