AddAction Flags

For developers using the Construct 2 Javascript SDK

Post » Thu Jul 23, 2015 11:37 am

Hi There,

I am new to Construct2 Community.

I am trying to achieve to create a plugin which is just do a simple math, alert result and return result to game like adding it to an array or to a textbox.

Code: Select all

edittime.js :

AddNumberParam("1st Number", "description bla bla");
AddStringParam("2nd Number", "desc bla bla");
AddAction(0, af_none, "Do Sum", "SUMZZ", "SUMZZ", "num1 + num2 .....", "DoMath");



Code: Select all
runtime.js :


Acts.prototype.DoMath = function (numa,numb)
   {
      var total = numa+numb;
      alert(total);
      //return total; actualy right now i dont have any idea how to return...
   };


I added a button to layout and when you click to button i expect see a single alert.. But when i click to button, it keeps showing same alert window non-stop..

Isnt there a way to run these actions once for every click ?
B
4
S
1
Posts: 4
Reputation: 358

Post » Thu Jul 23, 2015 3:21 pm

An expression like DoMath(a,b) might be better than an action in this case.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Fri Jul 24, 2015 6:29 am

Hey @rexrainbow,

Exp is better idea to return a value i agree..

On the other hand, On button's click event i want to run an Action. And i want to run it only 1 time instead of forever....
There must be a trick to run these actions only 1 time :)
B
4
S
1
Posts: 4
Reputation: 358


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest