View Full Version : Conditions and strings
arvid
November 18th, 2003, 06:05 PM
Got a crazy question, I didn't really expect this to work, but I thought I'd try and see what happens :D
To put this in a reorder node:
Value>0?"rgba":"rgb0"
..in order to have it skip the alpha if a certain value is larger than zero. Except it doesn't work with strings it seems.
It's for a macro, just experimenting with some stuff basically, so any other bright ideas are welcome :thumbsup:
arvid
November 18th, 2003, 06:32 PM
Sorry folks, I RTFM and found that all I needed was a little : to make an expression in a string-box, like so:
:node.value>0?"rgba":"rgb0"
:stupid: I've done this before, but never with rgba boxes ;)
Aruna
November 18th, 2003, 07:09 PM
Yesh.. You could use not the reorder node, but the colorx node. I do not think you can place a string into the reorder node. The only values I know that can go in there are r,g,b,a,0,1,l,n,z.
so in colorx, in your A channel, put in the if:else expression...
a>0?a:0 would say if alpha is greater than 0, set alpha equal to alpha, else leave alpha as black.
or I maybe you're looking for a>0?1:a. ? Not sure exactly what you're trying to do, but the ColorX node will help out with strings in the color channel.
Good luck!
Hugh
November 19th, 2003, 01:29 AM
I got the impression that it actually worked with the ':' in front.....
Also, the ColorX node is so slow.... I was trying to work something out for someone, and was shocked at how sluggish a relatively simple ColorX node made it....
arvid
November 19th, 2003, 02:37 AM
Yup, I thought of colorX but I wanted to optimize it a little more, cus like Hugh said, it's slow, and indeed it worked fine with the reorder! Just had to add the :
TFM says that you can put any sort of expression in any stringbox if you add the :, for example if you want to create an expression that updates the text in a text node,
:time<50?"not there yet":"oops, time flies!"
Cheers anyway :D
ericohman
October 15th, 2008, 07:36 AM
How can I make the if time statement read a value from another node?
:time=={Text2.text}?"yes":"no"
If Text2.text is for example 25 then I want my script above to work like :time==25
I've tried with a lot of different signs around Text2.text but I got tired of testing, does anyone know how you type?
EDIT: I found out that you can just type :time==node.parameter but the problem was that you can only script to number parameters, like xSize and things like that, not to text. Doesn't matter though because I was not gonna write a-z only 0-9 symbols...
Hugh
October 16th, 2008, 07:30 AM
Try this:
:time==atof(Text2.text)?"yes":"no"
If Text2.text is not something that can be converted to a number, then atof() will return 0