Forum Discussion
Is there a way to auto run some triggers in a loop until the results are met?
- 3 months ago
JavaScript is more elegant and efficient, but for a few variables, you can do it with a handful of triggers on a layer.
Demo: https://360.articulate.com/review/content/041f67c6-c44a-47e8-a301-632caa78772b/review
This just shows a layer that assigns 4 random numbers to 4 variables. If any are the same, it reruns the the layer until they are all unique. This is very brute-force, but very simple. The triggers are fast enough that even if it takes many attempts, it is still practically instant.
This could be modified with a few more triggers to be more elegant, recalculating each random number only if it matches one of the previous variables, but in the end it is essentially the same thing. Simple gets the job done.
As Nedim mentioned, if you try this with many variables, it could begin to slow down, or require too many triggers. In that case, JavaScript is the way to go.
I really appreciate all the assistance on this. Both in Javascript and via triggers. Thank you all for helping me out on this.
No problem at all! You actually inspired me to create a few different versions of this using both triggers alone and JavaScript. Here's one more version — just for the record and for others who might find this discussion useful. This version introduces a slight delay between each number’s appearance, while still ensuring all numbers have unique values.
Related Content
- 7 months ago
- 4 months ago
- 10 years ago