I have looked around and cannot find a working solution to my problem.
Background — the intended use is an easy to form for a live rpg group for calculating successes of a downtime action. By entering numbers into given form fields, the script calculates the total number of “dice” with values between 1 – 10 to be used. There is also a difficulty threshold that needs to be met on each “roll” of the “dice” to be considered a success.
I am having difficulties generating random numbers using totalDice as the size of the array. Once I have that down, I will need to find a way to count and display the total number of random numbers greater than the given difficulty threshold.
For a working example of what I have so far, see here.
I have a var = totalDice which provides the size of the random array. The values of the random numbers are 1 – 10.
For example, if totalDice= 220, I need 220 random numbers generated between 1 and 10.
Then I have var = totalDiff which provides a threshold that I need to compare against the random numbers generated. I need to find a way to take the array generated and count the number of instances that are => totalDiff.
Example: totalDice = 220, totalDiff = 6, totalSuccesses = x, where x = the number of elements => 6.
Any help is greatly appreciated.
Break this into chunks, that’s what functions are for.
Check:
Edit: If you just want the number of successes, make another function to count them: