[Closed] Random selection between 3 or more set numbers
Hi, Sorry about the no doubt dense question but if you don’t ask you won’t recieve.
I was wondering if it was possible to create a random selection between several pre set numbers like 50, 100, 150, 200 so either of them would be called randomly when asked.
I can imagine you could use a normal random value between 50 and 200 then run the resulting number through some script that checks wether it’s closer to 50, 100, 150 etc and rounds it up but I’d be lost on how to do that.
I’m not a Maxscript guy and have been bobbing in and out of tutorials in a vain attempt to learn it, but any help is much apreciated.
Here is one way
(
aRandomNumber = random 1 3
myNumber = case aRandomNumber of
(
1: "50"
2: "100"
3: "200"
default: "50"
)
print myNumber
)
Hi,
you could use an array to store your values and use a random index to get the value.
something like that:
(
Vals = #(50,100,150,200)
Index = random 1 4
MyVal = Vals[Index]
MyVal
)
That’s grand, I was sure there were multiple ways to get the same result. Many thanks for these, it’s always good to see these, it all helps figure things out later or to think of where they can be used later.
Hi,
If that’s all you want, I guess you can also do this:
50 * (Random 1 4)
Cheers,
Light
As with just about anything in 3ds Max there are multiple ways to achieve the same result.
-Eric