Forum

If then else on vvvv

hello!
couple questions related with the vvvv-slang:

1-Can some one point me how a conditional statement is declared in vvvv. Something like:
if input1 == input2 then bang

2-is there any way to have a modulo operation with an input value?:
x%value

Thank you for the help!!!
Emmanuel

herewith an example of what i mean

herewith an example of what i mean

condition.v4p (8.5 kB)

I made a little patch explaining what you need

I made a little patch explaining what you need

equal_and_mod.v4p (11.8 kB)

Also this thread is useful to read:
http://vvvv.org/tiki-index.php?page=Basic+Programming+Concepts&highlight=conditions

Just saw your patch

I made a new patch… basically you need to use FrameDelay (Animation) to make a feedback loop

Just saw your patch

I made a new patch… basically you need to use FrameDelay (Animation) to make a feedback loop

equal_and_mod2.v4p (16.4 kB)

wow, thanks for the help!
Any clue how to make the modulo value?
Emmanuel

the mod value is calculated in the little group of nodes to the bottom left of the equal_and_mod patches

If you have many if-thens,Ors,Ands,Equals,… actually a complex logical situation my favourite choice is automata.node, which is a finite state machine.
Tonfilm found a cool graphical tool and made a patch, for creating easily automata states and conditions. Check his page for its usage.
With automata.node you get both a bang, if state changed, and an event-long state, which you can transfer by sift.string or equal.string in a toggle on/off. It has just bangs as inputs.
Im always doing the “logic” or “brain” of my programs with this one. Something like: only if user hit this first, they will see this and can hit this and that now. If they hit this first, than nothing happens.

thanks for the update, frank.

adding a reset bang to get to the initial state was on my todo list. but i would make two iputs more, one boolean to enable the reset bang, and one string to give it a custom name (default is Reset) because if someone uses the “Reset” input already to get to another state in it could lead to a error.

Hey, thank you for all the answers, this is clearing up how vvvv manages data.
I was wondering, is it possible to script on vvvv?, maybe it would be an easier way to uses these operators.

@tonfilm: Good point. I just did it in a way I use it often. Keeping it more customizable is good style. Already uploaded ;) Btw thanks for your cool, time and nerves saving workflow.
@efe: Im at a point, where I use it as soon as Im going to need more than three logical operators (And,Or,Not) to get some bangs. Often it wont be limited to three only and then the mess starts, instead of having started with automata directly.

any practical usage examples of automata in action?

in all of my latest projects automata was the main control unit. the patch structure was like this:

user inputs -> logic -> graphical elements

it is always best to do a strict destinction between the logic and the graphics in a big patch. that means you hava one complicated patch with an automata, which has all states your patch can be in. from this patch you have many outputs that fade, enable or move in all of your graphical elementes.

have a look at the first picture on the graphical automata site, to get an idea of the state logic.

@sunep:
i cannot find the mod value, any hint?
thank you for the help

Now made a patch with just the mod part in it.

Now made a patch with just the mod part in it.

and_mod.v4p (3.9 kB)

hello. had a similar problem. automata is def. the best way to go. but here´s a simple example for “if then else” in an expression node.

cheers,

dd

hello!

couple questions related with the vvvv-slang:

1-Can some one point me how a conditional statement is declared in vvvv. Something like:
if input1 == input2 then bang

2-is there any way to have a modulo operation with an input value?:
x%value

Thank you for the help!!!
Emmanuel