Random numbers
ChillBox
Member, PRO Posts: 115
Hello,
I want to change attribute to a random numbers between 1 to 1000
I want that the Random numbers that have been selected not repeat themselves again.
how can I do that?
I want to change attribute to a random numbers between 1 to 1000
I want that the Random numbers that have been selected not repeat themselves again.
how can I do that?
Comments
Hello @Talo One way that works quite well for non-repeating random numbers is to use Tables.
So you'd make your attribute (let's call it MyRand) – give it a value of 1 more than your max. random number (so in this case, it'll be 1001).
And then a boolean for a loop if that's the way you're going to trigger it over and again, so I'll include that as a continuous loop, triggered every 3 seconds as an example.
Make your table with 1 column, each row cell the number from 1 to 1000 (or even a randomised order). Then make another blank Table called TRandUse.
Copy Table MyTable to TRandUse (so you can reset to the beginning again later if you wanted)
Display Text MyRand
Rule: When Loop is false
Change Attribute MyRand to random(1,MyRand-1)
Change Attribute MyNum to TableCellValue(TRandUse,MyRand,1)
Add/Remove Row Table: TRandUse Remove Row At Index MyRand
Timer: After 3 seconds
Change Attribute Loop to true
Rule: When Attribute Loop is true and MyRand > 0
Change Attribute Loop to false
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps