### Author Topic: Numeric selection method by index number  (Read 152 times)

#### Pixual

• Newbie
• Posts: 8
##### Numeric selection method by index number
« on: May 20, 2020, 12:38:33 PM »
Hi all,

I'm working on multiple scripts and I'm wondering how to solve the following:
I have tiles for which I use two types of patterns: 1. the 'segment > herringbone' macro and 2. the 'hexagonal padding' macro. In addition to this i'd like to change sizes of the tiles without scaling the texture, so I enabled the 'apply box mapping' feature in the segment node. When switching between the two macro's the tiles will rotate by 45 degrees. I'd like to add the (fixed) rotation number into the 'mapping>rotation' parameter of the segment node by switching between two numeric nodes via an index number (which corresponds to the index number for the tile bond macro selection).

Is selecting a numeric by index possible in Railclone?

Thanks, greetings,

Jakob

#### Dragan

• Hero Member
• Posts: 503
##### Re: Numeric selection method by index number
« Reply #1 on: May 20, 2020, 12:55:51 PM »
Yes, it is possible. Just add a new Arithmetic node and use IF statement to act as a selector:
e.g. You can use Inputs 1-4 as some values and Input5 as Selector Index
Input1 = 20
Input2 = 60
Input3 = 10
Input4 = 33
Input5 set to 1 - 4
-------------------------

RETURN
If(Input5==1,Input1,
Input5==2,Input2,
Input5==3,Input3,
Input4);

so. if You set Input5=3 your output will be value 10, for Input5=1 output will be 20 etc.

« Last Edit: May 20, 2020, 01:03:59 PM by Dragan »

#### Pixual

• Newbie
• Posts: 8
##### Re: Numeric selection method by index number
« Reply #2 on: May 20, 2020, 02:05:38 PM »
Thanks Dragan for the quick reply!
When i tried this out, two things occur.

I used the following expression:

RETURN
if (Input3==1,Input1,
Input3==2,Input2);

In the arithmetic node the first input is a 'constant' with a value of 45, second input is a 'constant' of 0 and the third input a 'numeric' which could be 1 or 2.

When i Evaluate this it says:

Compile error. Wrong number of arguments in function: "if" at line 2:
if (Input3==1,Input1,
^

Second point, if i try to wire this to an input for a segement mapping rotation it gives a warning as seen in the attachment. Because of the compile error it doesn't seem to give any output yet, any idea how to solve this?

Greetings, Jakob

#### Dragan

• Hero Member
• Posts: 503
##### Re: Numeric selection method by index number
« Reply #3 on: May 20, 2020, 02:24:16 PM »
In your case it is enough:

RETURN
if (Input3==1,Input1,Input2);

#### Pixual

• Newbie
• Posts: 8
##### Re: Numeric selection method by index number
« Reply #4 on: May 20, 2020, 02:30:02 PM »
Many Thanks Dragan! This works

#### Pixual

• Newbie
• Posts: 8
##### Re: Numeric selection method by index number
« Reply #5 on: May 29, 2020, 10:10:12 AM »
Hi!

The solution worked for a two choice selector. I'm working at something else and I'm in need for a selection of more input values. For a multi-choice selector as stated above by Dragan the solutution always gives the error I mentioned, even if I copy them. Is there something I do wrong entering these values?

Thanks!

Jakob

#### Dragan

• Hero Member
• Posts: 503
##### Re: Numeric selection method by index number
« Reply #6 on: May 29, 2020, 11:02:37 AM »
Hi,
My syntax on the previous example with multiply inputs was wrong

For example, you have 5 inputs:
Input1
Input2
Input3
Input4
Input5
and one to use as selector
Input6

If statement is look like this: IF(A,B,C) meaning; If A is true then B else C.

Return
IF(Input6==1,input1,
IF(Input6==2,input2,
IF(Input6==3,input3,
IF(Input6==4,input4,
input5))));

-----------------------------
For values 1-4 you are checking if input#==XX and if some of those are true that point will be your output and if none of those 4 is true input5 (the last one) will be taken as output.
So basically you are making a loop until the last one.

Sorry for previous confusion

« Last Edit: May 29, 2020, 11:32:13 AM by Dragan »

#### Dragan

• Hero Member
• Posts: 503
##### Re: Numeric selection method by index number
« Reply #7 on: May 29, 2020, 11:29:41 AM »
Here is the file containing the Macro for 10 numeric inputs.
Please, let me know if you need something more.
Best Regards