Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Rolling a variable number of dice, based on a stat

$
0
0
Hello,

First post, here :)

I'm setting up my first Twine game using sugarcube 2.x and I'm interested in some possibilities with the random macros.

I'm wanting to set up a situation where a character is able to roll a number of separate dice that depends on a previously generated statistic, for instance, rolling 2 dice if their statistic is 2; 3 dice if it is 3, etc.

I'd like the Twine to show the results of each dice separately, and then evaluate and count the number of 'successes' which have reached a target number.

I'm familiar with how to use, for instance:

<<set $l2t1 = random(1,6)>> <<print $l2t1>>

to generate a d6 roll and display it, and

<<if $l2t1 lte 4>> "You have failed"<<set $l2t1CHECK eq "FALSE">>
<<else>> "you have succeeded" <<set $l2t1CHECK eq "TRUE">>
<<endif>>

To evaluate success against a target number of 4 and log that success with another variable for later reference


...but is there a way to have the Twine iterate this process a number of times that is equal to a particular variable, and then log and print the results of each roll, as well as then the number of successes?

I'm imagining it printing something like:

"Your agility is 3"
"Your rolls are: 4, 1, 6"
"Those 2 successes are enough to pass the test"

I hope this is clear and I'm sorry if I have left anything out :)

Thanks heaps!

Viewing all articles
Browse latest Browse all 1844

Trending Articles