Can I make expanding input blocks?

Questions about GP commands and how to do things

Moderator: MSandro

Post Reply
mguzdial
Posts: 70
Joined: Sep 15th, '15, 11:21

Can I make expanding input blocks?

Post by mguzdial » Oct 19th, '16, 15:55

I want to create a mixer block that takes 2, 3, or 4 arrays of samples from sounds and returns a mixed sound. I've got the code working so that I accept three inputs and it will work with 1, 2, or 3 inputs -- but the "extra" inputs are still hanging around. Is there a way to create optional inputs all with blocks?

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Can I make expanding input blocks?

Post by JohnM » Nov 15th, '16, 15:50

Yep!

Start out by clicking the "Make a shared block" button in the "My Blocks" category and define your basic inputs and labels. In this case, I created a "mix" block with two input slots:
Screen Shot 2016-11-15 at 10.42.31 AM.png
To add optional inputs, click on the down arrow below the word mix. This will create new "block section", on a new line, that has a new set of labels and inputs. After doing this twice, my block definition looks like this:
Screen Shot 2016-11-15 at 10.52.05 AM.png
In the palette, the block appears with just the basic labels and input slots:
Screen Shot 2016-11-15 at 10.51.39 AM.png
Screen Shot 2016-11-15 at 10.51.39 AM.png (8.1 KiB) Viewed 6035 times
but you can click the expansion arrow to get this:
Screen Shot 2016-11-15 at 10.52.22 AM.png
Screen Shot 2016-11-15 at 10.52.22 AM.png (9.51 KiB) Viewed 6035 times
or this:
Screen Shot 2016-11-15 at 10.52.27 AM.png
Screen Shot 2016-11-15 at 10.52.27 AM.png (9.58 KiB) Viewed 6035 times
I hope that helps!

mguzdial
Posts: 70
Joined: Sep 15th, '15, 11:21

Re: Can I make expanding input blocks?

Post by mguzdial » Nov 15th, '16, 16:35

It does, thanks! "Repeat last section" didn't communicate to me that that's how we create flexible input. We might want to rephrase that prompt.

Post Reply