# The Regnus Scripting Tutorial

## Part 8: Inline Entry Selection

Literal expressions serve an additional, powerful purpose, in that they allow entry selection inline within a reference. For example:

``` START <Example>I once fought and killed a ##(dragon\mastodon\wyvern);! ```

If you run this script, you will find that the literal expression returns only one of the three creatures separated by backslash ("\") characters. As you can see, for simple entry selection, this is much simpler, as it removes the necessity for additional groups.

(Of course, should you wish to use backslash characters in an inline expression, they can be escaped as usual using the overstep (asterisk) character!)

As each option is fully parsed, there is no limit to how complex a nested selection can be! For example:

``` START <Example>I once fought and killed a ##(mastodon\troll\##(dragon\##(red wyvern\black wyvern);\wyrm););! ```

Entry weighting is not supported for this type of entry selection, so each option in a particular literal expression has an equal chance of selection. Thus in the above example, the results "mastodon" and "troll" each have a one-in-three chance of selection, as does the further reference containing various different forms of dragon; and within this reference, the options "dragon" and "wyrm" each have a one-in-three chance of selection, as does the further reference containing the two colours of wyvern, each of which has a fifty/fifty chance of selection.

Of course, for more complex scripts, inline entry selection like this can become very convoluted, so it is usually best used for simple one-off text replacements where the addition of a full group would be excessive, but as you can see, the possibility for nesting is very useful when appropriate!