Random selection from a changing set of values?
shortwave
Member Posts: 29
Just wondering if anyone could help me with this one...
I have ten boolean attributes, like box1, box2, box3 etc. They can all be turned on and off with buttons.
Then I need to randomly choose one of the boxes which is turned on. So for example:
Box 1, Box 4, Box 6 and Box 7 are all turned on, then when a button is pressed, one of those four numbers is randomly chosen.
I can see how to do this using tables when you have a set list of values, but not quite sure how to approach it when the numbers themselves can change...
Thanks!
I have ten boolean attributes, like box1, box2, box3 etc. They can all be turned on and off with buttons.
Then I need to randomly choose one of the boxes which is turned on. So for example:
Box 1, Box 4, Box 6 and Box 7 are all turned on, then when a button is pressed, one of those four numbers is randomly chosen.
I can see how to do this using tables when you have a set list of values, but not quite sure how to approach it when the numbers themselves can change...
Thanks!
Comments
You can then pick a random on button from the on table because it will only contain on buttons.
You could probably do this without the off table if you don't need to find out which ones are off in your game