I'm trying to take incoming points from a particle sim that has a hitnum attribute that is either 0 or 1. Inside the attribute wranger, No matter what I do I can't get the if statement to work. I get “synax error, unexpected if”
f@flame = if(@hitnum > 0, .25, 1);
Problem with IF statement
2261 4 2- eschwab
- Member
- 63 posts
- Joined: 9月 2014
- Offline
- eschwab
- Member
- 63 posts
- Joined: 9月 2014
- Offline
Well I found the answer on https://www.tokeru.com/cgwiki/index.php?title=JoyOfVex11 [www.tokeru.com]
The thing I don't get is why is this information not on sidefx's documentation? Or at least I couldn't find it in any of the vex functions or expressions.
The correct formatting would be as follows for anyone else that finds this.
if(@hitnum>0.0) {
f@flame = .25;
} else {
f@flame = 1;
};
The thing I don't get is why is this information not on sidefx's documentation? Or at least I couldn't find it in any of the vex functions or expressions.
The correct formatting would be as follows for anyone else that finds this.
if(@hitnum>0.0) {
f@flame = .25;
} else {
f@flame = 1;
};
- ati
- スタッフ
- 207 posts
- Joined: 11月 2019
- Offline
You should find it under the vex section:
https://www.sidefx.com/docs/houdini/vex/statement.html [www.sidefx.com]
However it is indeed missing some other possible formatting you can use.
For example your code could be written in one or two lines as well:
f@flame = f@hitnum > 0 ? 0.25 : 1;
or
if (f@hitnum>0) f@flame = 0.25;
else f@flame = 1;
https://www.sidefx.com/docs/houdini/vex/statement.html [www.sidefx.com]
However it is indeed missing some other possible formatting you can use.
For example your code could be written in one or two lines as well:
f@flame = f@hitnum > 0 ? 0.25 : 1;
or
if (f@hitnum>0) f@flame = 0.25;
else f@flame = 1;
Edited by ati - 2020年12月5日 03:52:16
- eschwab
- Member
- 63 posts
- Joined: 9月 2014
- Offline
Thank you for this. I did see that but it wasn’t as clear as you’ve made it. I guess the other format that I was using “if(statement, true, false)”is only for expressions and not in vex. Although that format is considerably easier than the C inspired one for vex.
I’m fairly competent at python but not C. Is the ? Operator a common use? I’ve never seen that before.
I’m fairly competent at python but not C. Is the ? Operator a common use? I’ve never seen that before.
- goingbananas
- Member
- 27 posts
- Joined: 3月 2020
- Offline
-
- Quick Links