A neat trick to use a variable to affect what *rand can roll.

I’ve been using choicescript since August 2011 and even now I’m learning neat tricks.

Writing Quiver let me learn that you can use a variable to exercise some control in the *input_number command.

Which I used so the amount Robin can give silver to the poor will never exceed what they actually have.

*input_number gift 1 {silver}

So if Robin has 50 silver they can input 1 - 50, but if they’ve got 100 silver they can input 1 - 100.

I saw someone bringing up the *rand command in a different post and it got me considering whether something similiar would work for that. For example lets say someone is writing a DnD style game where they role dice and the player has to make a strength check.

So I tried it and it actually works. [*rand dice 1 {strength}] which will roll between a 1 and whatever the {strength} stat is at that point.

I think that’s quite cool so I thought I’d share it considering I’ve not been in the interactive-fiction zone lately so have been working on a novel instead of Quiver, and this might help someone else!

16 Likes