Emulating three pounds of dice

So, trying to figure out how to set up a script for, well, emulating certain dice mechanics is proving a headache.

Specifically, what I'm basically trying to work out is how to emulate is something like the Storyteller system (White Wolf: Exalted and World of Darkness), where you have your pile of dice (10-sided ones, in the case of Storyteller), you roll a number equal to your stat, and count successes, which would be, say, all dice showing 8, 9 or 0. I want to find out how I can set up a die roll with, say, a number of dice equal to an Actor's Atk stat, then check how many dice show each value. (Presumably, the most practical solution would be to output one variable for each possible result - Ones, Twos, Threes and so on - equal to the number of dice with that result, but I'm stumped on how to pull this off.)

Of course, if there's no practical way to do this, then that's that, and I'll have to use other mechanics, but... it'd be nice to be able to emulate the "Count your Successes" mechanic.

I've also got a few secondary uses I could make of it, but that's an extrapolation I think I'd be able to pull off at a later time.
I'm not really sure I follow you, so here's an example based on what I THINK you're trying to do. At least, hopefully, it'll give you a starting point.

total = 0actor.atk.times {|i| total += 1 if [8,9,0].include?(rand(10))}Starts off at a count of 0.Rolls the dice a number of times based on actor.atk (actor is an object - you will have to use the correct terminology based on the context you're running this under).

If the roll results in 8, 9 or 0, adds 1 to the total.

Gives you the total number of dice rolls that resulted in 8, 9, or 0.
That... does look like exactly the basic formula I was looking for.

Hmmm... if I wanted the tens (well, zeroes) to count as two successes, would I write the second line like

actor.atk.times {|i| total += 1 if [8,9].include , total +=2 if[0].include?(rand(10))}

...or am I madly careening off the wrong track here?
yeah, you can't use that kind of syntax.

You could do either of these:

Code:
actor.atk.times {|i|  roll = rand(10)  total += 1 if roll == 8 or roll == 9       # this is the same as saying if [8,9].include?(roll)  total += 2 if roll == 0}
or
Code:
actor.atk.times {|i| total += [2,0,0,0,0,0,0,0,1,1][rand(10)]}
The second method is better if you want to give different results based on a number of different values. The first is probably okay if you're just interested in a small number of comparisons.
Oooooh, the first method is also better if I want to count sets - different variables for each "side", suitable for... well, assorted things.

My thanks - you just saved me ages of trial, error and manual checking (in that order, most likely). 😉
Actually, here's a better solution ...

total = 0actor.atk.times {|i| case rand(10) when 0 total += 2 when 8,9 total += 1 end}# do whatever you need to with total hereI THINK that's the right syntax.It's more efficient because it's not going to check each individual condition.
And there I think I see how I can make D&D-style damage dice, too... Awesome. :3

Original thread: https://forums.rpgmakerweb.com/threads/emulating-three-pounds-of-dice.38019/