Difference between revisions of "Storybook:Option"

From Wiki Salad
Jump to: navigation, search
Line 33: Line 33:
 
==Default options==
 
==Default options==
 
'''Default options''' appear on any page where no other options would be displayed, usually because the story has come to an end. It's a good idea to give the reader an option to start over. If you do, then you'll usually want to put <tt>memclear</tt> in your script to clean out your scripting variables.
 
'''Default options''' appear on any page where no other options would be displayed, usually because the story has come to an end. It's a good idea to give the reader an option to start over. If you do, then you'll usually want to put <tt>memclear</tt> in your script to clean out your scripting variables.
 +
[[Category:Storybook]]

Revision as of 14:08, 10 January 2013

An option is a selectable choice that can appear on a page. Authors who are interested in writing a Choose Your Own Adventure-style book need only concern themselves with the option text and destination page, but options offer advanced features for extra flexibility.

Option text

The text displayed to the reader. You can use the same variables and markup here that you use in page text.

Destination page

The page the reader will be on after selecting this option. The option script can override this; see below. If this field is left blank or contains an invalid page number, the destination page will be the current page.

Conditions

A scripting expression. If the expression evaluates to true or the field is blank, then the option will appear on the page; otherwise, the option will not appear to the reader.

An expression is what you might find in an if statement. For example:

Right:

a > 3 || b < 2

Wrong:

if (a > 3 || b < 2)

Script

A script that is executed after the option is selected, but before the script for the destination page is executed. If you use goto in this script, the destination page will not be processed at all (unless goto fails to load a valid page, or happens to point to the destination page).

Text when selected

A block of text that will appear at the start of the next page, no matter what page that turns out to be. It is prepended to the actual text of that page. This field is optional, and you can accomplish the same effect with a variable. You usually want to put some space at the end of this text, since the engine doesn't add any for you. In other words, if your "Text when selected" is "Hello" and the destination page text is "World", then the page will display "HelloWorld".

This text is evaluated after all of the scripts have run. Keep this in mind if you're using variables that could change before the page is displayed.

Global options

You can set up global options for your book that will appear on every page (as long as the option's conditions are met). Global options are useful when you plan on offering the same option on many pages. For example, if your story has items that the reader should be able to use at any time, you can make them usable as global options.

Remember that you can use conditions to control whether your global options appear.

Default options

Default options appear on any page where no other options would be displayed, usually because the story has come to an end. It's a good idea to give the reader an option to start over. If you do, then you'll usually want to put memclear in your script to clean out your scripting variables.