0 votes
by (120 points)
Working on an rpg-esque sample story in Harlowe. This will be used as an example for an intro coding course for youth, so I would like to avoid using java or anything outside of the included twine commands.

I want to let them rank three stats at the beginning (Strength, Dexterity, and Wisdom, for what it's worth) and let these affect their success at certain choices they make within the story, shown by giving them random "die rolls" and comparing them to a target number, with the stats they ranked higher getting a better chance of success. My original plan was to set each stat to a variable with a number range, so that their high stat would be 3-18, mid stat 2-14, low stat 1-8, and then when they chose an action the corresponding stat variable would be asked to spit out a random number and compare it to the target value. My problem is that I (incorrectly) though assigning a variable to (random: 1-8) would have it keep randomly selecting values, instead of selecting that value once and sticking with it.

Is there any way to do this that wouldn't require a ton of code for every test? I thought perhaps arrays or datasets would help me, but haven't been able to sort it out yet. Since I want them to be able to play through with different choices for stat rankings, I need to be able to set it at the beginning and have later tests be able to reference what they selected for their high and low stats.

Thanks for any assistance!

1 Answer

0 votes
by (63.1k points)

Is there any way to do this that wouldn't require a ton of code for every test?

I don't know that (set: $var to (random: $min, $max)) would count as a ton of code in every test.  Beyond that, I suppose you could set the roll in the passage header (or footer) to have it roll on every passage transition, but you'd be limited to one check per passage; i.e.

::somewhere else in the story
(set: $min to 3)(set: $max to 18)

::header [header]
(set: $roll to (random: $min, $max))

 Or something like that; you might need to make different variables for every roll, and generally I feel like this will be more work than just adding one line to your checks.