Synopsis:
A library to provide functions that are useful to writers regardless of the adventure system they are using.
Description:
While every gamebook system is unique there are tasks common across nearly every flavour – most notably rolling dice. This library attempts to address those needs.
Function List:
- &dice($number)
Rolls a number of six sided dice and returns the total.
Example:
$strength=&dice(3);
Will store the roll of 3 dice in the variable $strength – this will be in the range of 3 to 18. The significance of using the dice function to do this over just using the SEL &rand() function is that numbers at the periphery of the scale e.g. using 3 dice the totals 3 and 18 are far less frequent than numbers in the mid-range e.g. 10.
- &dnd_dice($number, $sides)
Rolls a number of dice with the specified number of sides (paper based role play games use dice with different numbers of sides) and returns the total.
Example:
$hitpoints=&dnd_dice(2,8);
Rolls two eight-sided dice and stores the result in $hitpoints. Again the significance of using dice rather than the &rand() function are the same as that detailed in &dice().
- &display_compact_list($separator,@list)
Prints the supplied list where differing values are separated by the character(s) supplied by the $separator parameter and where all values that are identical are displayed after an enumeration indicator, the * symbol.
Example:
&display_compact_list(‘ ‘,’sword’,’armour’,’sword’);
Displays: ‘sword*2 armour’
Note: use ‘n’ as the seperator to make each value display on a new line.
Note: This function does not return a value though thinking about it, it ought to return the output string rather than printing it directly. Will make different version sometime.