add two numbers in javascript?

0 favourites
  • 6 posts
From the Asset Store
Add SubRip (SRT) subtitles to your videos in Construct 3
  • 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?

  • It's not feasible, or not feasible for you?

    Couldn't you just use Ajax to get the numbers?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Returning is documented here:

    scirra.com/manual/24/ace-implementations

  • 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

  • You can only pass strings/float/integer between Plugins and Construct 2.

    But since JSON exists, this shouldnt be a problem

  • Hello Vuuv, Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)