I’m writing a script that requires me to select a random subtool from a pre-defined set (based on the Index assignments, up to 4). The actual subtool index is stored in a variable array: sToolID(0-3). The number of user assigned subtools is stored in stAssigned.
I start to run into problems however with the random number generator. If I put it in a loop, I can see that the picks random values, but it gets sequentially smaller. So in my script I only end up picking stID 1 or 2 once or twice, then I’m always randomly picking stID 0 there-after.
Anyone else have issues with the random number generator? Should I be resetting the random generator after every random result?
[VarSet, stIndex, [IGet, "ZPlugin:Toolbox:ST Index"]]
[SubToolSelect, sToolID([Var,stIndex])]
[Randomize]
[Loop, 20,
[VarSet, randomID, Rand([Var,stAssigned])] ///---randomly pick a subtool from the pre-defined user set
[note, [StrMerge, "random: ", #randomID],,0.5]
[VarSet, randomID, Int(#randomID)]
[note, [StrMerge, "random: ", #randomID],,0.5]
]
Also… I just re-made this thread in the help forum, I realized that I accidentally originally made it in the utilities forum. I apologize! Can a moderator delete the one in the utilities forum?