Structure "repeat"

wayna's picture

Hello all! Does anybody has a way to "repeat" a structure inside an iterator, or with javascript? I will try to explain myself I have an input structure with x members, for example: "0"=1 "1"=0 "2"=4

i want it to be repeated x time so the output would be like (if repeated 1 time): "0"=1 "1"=0 "2"=4 "3"=1 "4"=0 "5"=4

I can't find the way on how to do that, i think there is an easy way with Javascript, by i'm not very good at it If somebody has a tip, it would be greatly appreciated! Thanks in advance!

smokris's picture
Re: Structure "repeat"

Use the Range patch. Connect the current iteration to Value, set Range Min to 0, and set Range Max to the highest allowed index in your structure (i.e., the Structure Count minus 1). Then feed the Rolled-Over Value to Structure Index Member. You can then increase the Iterator's number of iterations as high as you like, and the structure will repeat to fill it.

wayna's picture
Re: Structure "repeat"

Thanks for the tip!

I can't get it to work tough, maybe i have done something the wrong way. I attach you the composition, i you have time to have a look maybe you'll find the mistake.

Many thanks

PreviewAttachmentSize
structure repeat.qtz32.2 KB

smokris's picture
Re: Structure "repeat"

There were a couple misplaced cables — you need to connect Current Index to the Range patch's Value input, and you need to connect the Structure to the Structure Index Member patch. Try the attached version.

PreviewAttachmentSize
structure repeat.qtz31.54 KB

wayna's picture
Re: Structure "repeat"

That is perfect! Thanks to you, now i have to achive something good with this ;)

cybero's picture
Re: Structure "repeat"

just compare and contrast betwixt your draft and the version of a structure repeat posted by smokris.

you need to have your sprite as the same size to get the same result 0.5 for a start off.

you need to have the current index feeding into the Range value input.

you need the Structure input from the Kineme Structure Maker to go into the Structure input on the Structure Index Member

you need the Range's Rolled over value going into the Structure Index Member's Index input

you will thus find you have a superfluous Structure Index Member - get rid of it ....

finally you need to feed the Iterator Variable's Current Position output fed into the Sprite's X Position.

Done and dusted.

wayna's picture
Re: Structure "repeat"

Yes, in fact i find it a bit hard to work inside iterators, because i don't really know what is happening. For example i don't really know why we have to use the range patch to achieve what i needed.

So most of the time i just mess around and see what happens, but when it can bee a big waste of time when i want something in particular.