Sum the value of two widgets?

Hi folks,

Imagine i have two XY pads.

One has a range of 100 to -100 on the X&Y.

The other has a range of 10 to -10 on the X&Y

I would like the value i send to be the sum if the two pads.

So if, for example i have:

pad#1: x = 15, y = 30
pad#2: x = 2, y = 6

Then the output should be:

x = 17, y = 36

Is something like that at all possible, and if so, how?

Thanks!

Create an input widget with value set as follows:

JS{{

var xy1 = @{xy_1}
var xy2 = @{xy_2}

return [xy1[0] + xy2[0], xy1[1] + xy2[1]] 

}}

You can use the input widget to send the value (ie set its address, target, etc)

Thanks, perfect!

I’m starting a JavaScript course so i can learn this stuff myself!

One quick question: it’s not clear to me what the difference is between the “value” and “script” fields.

Could you tell me why i need to sometimes use one or the other to perform these various trick and tweaks?

value could be seen as the widget’s input (when this property changes, the widget’s value is updated), script could be seen as its output (when the widget’s value is updated, the script is executed).

Great, thanks for explaining!

I am also interested to look at Java script course. Have you found a good one online? Maybe you can recomend some?

Thanks!

Nice, i started this one, it’s paid but the first 40 lessons are free, after that i think it’s like $50 or something to unlock the whole course. Seems pretty well put together:

www.learnjavascript.online

1 Like

you have this too : https://developer.mozilla.org/fr/docs/Apprendre/JavaScript

1 Like