Jump to content
Gabriel_Wolf

What is wrong with my code

Recommended Posts

Hello, 

I decided to finally start to learn vex. But I think now I rather suicide. :)

Can you tell me what is wrong with this code?

if (@P.y > 0){

v@Cd = set(0,1,0);}else {
v@Cd = set(1,0,1);}

if (v@Cd == set(0,1,0));{
v@N = 5;}

 

So basically I what is above zero should be green. And what is green should be get a normal with value of 5.

 

Thank you
 

Share this post


Link to post
Share on other sites

Hi Gabor, it seems to work as expected. You can assign v@N = 5, but when doing so, you are abusing the syntax a bit. Houdini casts that 5 into a vector {5,5,5}

Did you want something like this?

if (@P.y > 0) {
    v@Cd = set(0,1,0);
}else {
    v@Cd = set(1,0,1);
}

if (v@Cd == set(0,1,0)) {
    v@N = {0,5,0}; // I changed this line
}

 

image.thumb.png.0a99690edf894c465274101e2310e654.png

Share this post


Link to post
Share on other sites

Or maybe you wanted this?

if (@P.y > 0) {
    v@Cd = set(0,1,0);
}else {
    v@Cd = set(1,0,1);
}

if (v@Cd == set(0,1,0)) {
    v@N *= 5; // this line changed
}

 

image.thumb.png.8d25995404baab3d7abcd5635b73ac09.png

Share this post


Link to post
Share on other sites

Hello,

 

Thank you for your help. I see the issue was I put a semicolon after this: if (v@Cd == set(0,1,0)). 

Edited by Gabriel_Wolf
  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×