hello,
I have a problem with random values : I write
-------
for bbb = 1 to 12 do
(
a=#(0,0,0,0,0,10,10,10,10,10,10,10,10)
print ( random a[1] a[bbb])
)
---------
when execute I have :
0
0
0
0
0
0
9
10
2
8
1
10
OK
why don't I have just 0 and 10 value as result ?
Thanks for help.
Forum topic · General Scripting
random question
By titane357 · 2013-11-05
Description
Comments (4)
.
miauu · 2013-11-05
The way that you use it the rando generates values between 0(a[1]) and the value of bbb, which is from 1 to 12, so you will have random values 4, 6, 7, 2,
To have only 0 or 10, the elements in the A array use this:
(
for bbb = 1 to 12 do
(
a=#(0,0,0,0,0,10,10,10,10,10,10,10,10)
print a[( random 1 a[bbb])]
)
)
The random generated value must be used as index of the A array, so do not use a[1], because it is 0 and maxscript array are 1-based.
titane357 · 2013-11-05
Thanks Miauu, sometimes I Wonder if I have a brain...
.
miauu · 2013-11-05
Not only you have such thoughts. :)
titane357 · 2013-11-06
:-)