Store and update a variable when different events happen?

Is there a way to store the value of a variable, then have it update by one each time different events happen with other widgets?

I have a global variable set to zero on page load. When I drag/drop a widget, I want it to increment by one, [[globalVar + 1]]. Then I want to take that updated variable value “store” it and increment by one again when I drag/drop a second widget. Is something like this possible?

I have not been able to find a way to store the new value of the variable, so my workaround has been to update the variable by 2 when the second widget is dropped, [[globalVar + 2]]. Thanks.

You can use the Update Variable Value action to set [[GlobalVar]] to [[GlobalVar+1]]. If you want multiple different widgets to trigger the same action (increment GlobalVar by 1) what I tend to do is centralise that logic on a hidden widget.

So for example, you might have a ‘CountUp’ hidden widget (this can be anything, like a rectangle) which will always update GlobalVar to GlobalVar+1 when clicked. Hide this widget, then have your other widgets fire click events at it when something happens to them (like they get clicked or dragged).

If there’s an aspect of your question I’m missing, please upload your .rp file so other members can help.

Thanks for replying. I am unaware of an Update Variable Value action in RP9. Are you referring to the Set Variable Value action?

Sorry, yes. You can use Set Variable Value to both initially set and update the value of a global variable.

Awesome, thanks for the help I was able to get.