random question

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.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

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's picture

Thanks Miauu, sometimes I

Thanks Miauu, sometimes I Wonder if I have a brain...

miauu's picture

.

Not only you have such thoughts. :)

titane357's picture

:-)

:-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.