syntax question

Danjel van Tijn's icon

I took a break from max/msp for quite a while and was doing more traditional coding. Now I am back and bashing my head against the wall trying to do something that is so simple in C but can't figure out how to do in max:

What is the equivalent to having a variable that gets reset to zero every time after it has been read?

I want to have three random number generators that are triggered by three different keyboard keys. If any one of these keys is pressed, I want three values to be sent (the other two should be a value of zero) at the same time. If two keys are pressed then there should be two random values and one value of zero.

I bet there is a really simple way to do this and I am doing something the long way!

Danjel van Tijn's icon

I think I figured it out.

I just use a Pak object and then have it reset itself to 0. 0. 0. using the set message triggered by every new output.

swieser1's icon

Another way...

Max Patch
Copy patch and select New From Clipboard in Max.

Luke Hall's icon

I agree, [pak] and the "set 0 0 0" message are the way to go here. Here's a method that lets you set the random range and offset for each individual channel as well.

lh

Max Patch
Copy patch and select New From Clipboard in Max.