Why is it Wrong typing "v@P += (0,@mask*3,0); "?

   313   3   0
User Avatar
Member
8 posts
Joined: Aug. 2023
Offline
One simply Vex code.

It doesn't make sense When I type v@P += (0,@mask*3,0);

But it works to type v@P.y += @mask*3;

I want to know why? And how to write it correctly in the first way?

Attachments:
Screen1.png (1.5 MB)
Screen2.png (1.2 MB)

User Avatar
Member
209 posts
Joined: Jan. 2013
Offline
The first option will create the value of only the last element. You can check this if you write, for example,
v@P += (0,@mask*3,10);
You can see that the remaining elements have no effect on the expression.
To make it work as a vector you need to change the example a little.
v@P += set(0,@mask*3,10);
User Avatar
Member
8 posts
Joined: Aug. 2023
Offline
alexwheezy
The first option will create the value of only the last element. You can check this if you write, for example,
v@P += (0,@mask*3,10);
You can see that the remaining elements have no effect on the expression.
To make it work as a vector you need to change the example a little.
v@P += set(0,@mask*3,10);
Oh, alexwheezy, thanks a lot!
It works when I use set(0,@mask*3,10);

And I've noticed that claiming a vector should use {} instead of ()
so it also work when I type:
v@P += {0,5,0};

But be carefully ,it occur an error if you reference a property @mask ,like this:
v@P += {0,@mask,0};

so in my case, the best way is to use v@P += set(0,@mask*3,10); like you say.

Attachments:
ScreenS1.png (3.5 MB)

User Avatar
Member
209 posts
Joined: Jan. 2013
Offline
jackdon4682
And I've noticed that claiming a vector should use {} instead of ()

Yes, this form only works with literal constants. Trying to use something else will cause an error.
  • Quick Links