I just thought I would post this in case anyone else needs something similar.
Basically what is happening here is I populate an array with random numbers within a range, without repeating any numbers.
I know it can be simplified (use less lines of code) but I broke it out to hopefully make it easier to understand and learn from. Enjoy, and feel free to comment.
CustomScriptCodeLocalVariablesL_ClearArray=0<Integer[10]>
L_ShuffledArray = 0 <Integer[10]>
L_TotalPicksAllowed = 0 <Integer>
L_TotalLeftToPick = 0 <Integer>
L_RandomInt = 0 <Integer>
Actions
------- This determines how many numbers you want to pick randomly
Variable - Set L_TotalPicksAllowed = 10
------- This will be used to keep track of how many more need to be picked
Variable - Set L_TotalLeftToPick = L_TotalPicksAllowed
------- This sets the ClearArray[] to 1[1], 2[2], 3[3]... 10[10]
General - Pick each integer from 1 to 10, and do (Actions)
Actions
Variable - Set L_ClearArray[(Pickedinteger)] = (Picked integer)
------- This chooses random values (quantity of random choices is determined by L_TotalPicksAllowed)
------- from the L_ClearArray and then removes them from being within range of being picked again
General - Pick each integer from 1 to L_TotalPicksAllowed, and do (Actions)
Actions
Variable - Set L_RandomInt = (Random integer between 1 and L_TotalLeftToPick)
Variable - Set L_ShuffledArray[(Pickedinteger)] = L_ClearArray[L_RandomInt]
Variable - Set L_ClearArray[L_RandomInt] = L_ClearArray[L_TotalLeftToPick]
Variable - Modify L_TotalLeftToPick: - 1
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I just thought I would post this in case anyone else needs something similar.
Basically what is happening here is I populate an array with random numbers within a range, without repeating any numbers.
I know it can be simplified (use less lines of code) but I broke it out to hopefully make it easier to understand and learn from. Enjoy, and feel free to comment.