So In my app I want there to be a feature where every set amount of time a random “challenge” is displayed on the screen. I was wondering how I could do this in a way that I can put in the “challenges” beforehand, I think I could use a data source somehow, but I am not completely sure.
Yes, add each challenge as a separate row in your data source. Set a variable to the list of values from one column of the data source.
Then, when you want to select a random challenge, get and remove a random item from the list and set a variable to it. Display the variable in a label.
Before I try what you have said above, does this spreadsheet look like what you had in mind?
*The Challenges are just examples, they don’t matter what they are.
So It almost works, When I click the button it changes from “Your Challenge is…” to " null" then I click it again and it shows all of the challenges at once in 1 long list, Here are some photos:
The list of values block is already a list. When you add a (gear) list block in front of it, you make a list of lists which is not something you generally should do. Please remove the (gear) list block and see if that helps.
It works, but sometimes because the challenge is random the same challenge theoretically could be done twice in a row, so is there a way to make it so it does not repeat the perivous challenge?
Yes, that’s why I mentioned the get and remove block before.
Instead of getting a random item from the list, choose a random number from 1 to the length of the list. Set a variable to that random number value. Then, get and remove the item at index [random number variable].
It works slightly better, about one in 12 times I click the button the challenge result will be the same as before so I would have to press the button twice, but unless there’s an easy way to fix it, then it should not be too much of a problem.
What I mean is I would still like them to eventually cycle thought randomly like what I had at the start except not to randomly select the same challenge from the data source twice in a row, because later on I don’t what to be having to type out all the challenges in my spreadsheet after every time someone uses my app.