- "RPG dice" - like d4 to d100 with modifiers
- "Success Pools" when several of the same kind of dice are rolled, some being success and optionally failure
- "FATE dice" that have -1,0 and 1 sides (also called Fudge dice occasionally)
RPG Dice Widget
/****************************
* <<RollRPGDice #dice die_size +die -die +total -total>>
* args[0] - the number of dice to roll
* args[1] - the max number on single die
* args[2] - # add to each die
* args[3] - # subtract from each die
* args[4] - # add to total of all dice
* args[5] - # to subtract from total of all dice
* !! must have all arguments, use 0 as default !!
******************************/
<<widget "RollRPGDice">> <<nobr>>
<<set $results = []>>
<<set $rolltotal = 0>>
<<for _i = 0; _i < $args[0]; _i++>>
<<set _roll = random (1, $args[1]) + $args[2] - $args[3]>>
<<run $results.push (_roll)>>
<</for>>
<<for _t = 0; _t < $results.length; _t++>>
<<set $rolltotal = $rolltotal + $results[_t]>>
<</for>>
<<set $rolltotal = $rolltotal + $args[4]>>
<<set $rolltotal = $rolltotal - $args[5]>>
<br> Your Rolls: $results
<br> Total = $rolltotal
<</nobr>> <</widget>>
Roll 3d4
<<RollRPGDice 3 4 0 0 0 0>>
Roll 2(d6+3)
<<RollRPGDice 2 6 3 0 0 0>>
Roll 3(d8-2)
<<RollRPGDice 3 8 0 2 0 0>>
Roll 4d10+20
<<RollRPGDice 4 10 0 0 20 0>>
Roll 3d12-6
<<RollRPGDice 3 12 0 0 0 6>>
Let's do a variable to roll 3d4, with x = 4
<<set _x = 4>>
<<RollRPGDice 3 _x 0 0 0 0>>
Success Pool Widget
/****************************
* <<RollDicePool #dice die_size +die -die #Success #Failure>>
* args[0] - the number of dice to roll
* args[1] - the max number on single die (die type)
* args[2] - # add to each die
* args[3] - # subtract from each die
* args[4] - # >= counts as a Success
* args[5] - # <= counts as a Failure/Botch
* !! must have all arguments, use 0 as default !!
******************************/
<<widget "RollDicePool">> <<nobr>>
<<set $results = []>>
<<set $Success = 0>>
<<set $Fails = 0>>
<<for _i = 0; _i < $args[0]; _i++>>
<<set _roll = random (1, $args[1]) + $args[2] - $args[3]>>
<<run $results.push (_roll)>>
<</for>>
<<for _t = 0; _t < $results.length; _t++>>
<<if $results[_t] gte $args[4]>>
<<set $Success += 1>>
<<elseif $results[_t] lte $args[5]>>
<<set $Fails += 1>>
<</if>>
<</for>>
<br> Your Rolls: $results
<br> You have $Success Successes
<br> You have $Fails Failures/ Botches
<</nobr>> <</widget>>
5d10 Success 8+ No Fail
<<RollDicePool 5 10 0 0 8 0>>
8d6 Success 4+ Fail 1-
<<RollDicePool 8 6 0 0 4 1>>
Fate Dice Widget
/********************
* <<RollFateDice #dice>>
* args[0] - the number of dice to roll, by default this is
* 4 dice, but I'm leaving it a variable for flexibility
*********************/
<<widget "RollFateDice">> <<nobr>>
<<set $results = []>>
<<set $rolltotal = 0>>
<<for _i = 0; _i < $args[0]; _i++>>
<<set _roll = either (-1, 0, 1)>>
<<run $results.push (_roll)>>
<</for>>
<<for _t = 0; _t < $results.length; _t++>>
<<set $rolltotal = $rolltotal + $results[_t]>>
<</for>>
<br> Your Rolls: $results
<br> Total = $rolltotal
<</nobr>> <</widget>>
Roll the standard 4 dice
<<RollFateDice 4>>
Roll 6 dice, for the heck of it
<<RollFateDice 6>>
Hopefully there are all easy enough to copy and paste into your Twine story, if you need something like this :)
How would I use the result to set a variable such as roll 3 d 6 for strength---macro yields result---set $str to that result
ReplyDeleteNext roll for a different stat to set a different variable.