The *goto command is used for "jumping" from one line to another within the same scene file. (For loading a completely new scene file, see the *goto_scene and *finish commands, respectively).
Usage
*goto is always used in combination with a *label name, being the means by which you tell it where to go. This is known as its reference. For example:
*goto Next (some Other Stuff here) *label Next
In the above example, when its hits the *goto Next line it will immediately "jump" to the *label Next line and then continue on from that line, completely bypassing any Other Stuff in between.
*goto and *label combinations are typically used within a *choice statement, as follows:
What do you prefer? *choice #A donkey. You prefer a donkey! *goto Donkey #A horse. You prefer a horse! *goto Horse *label Donkey What color do you want your donkey to be? *choice #Red. You prefer a red donkey! *finish #Green. You prefer a green donkey! *finish *label Horse What color do you want your horse to be? *choice #Red. You prefer a red horse! *finish #Green. You prefer a green horse! *finish
*goto and *label are also commonly employed as a result of *if, *elseif and *else conditions, as follows:
*if horse You prefer a horse! *goto HorseColor *elseif donkey You prefer a donkey! *goto DonkeyColor *else You don't prefer anything! *finish *label HorseColor What color do you want your horse to be? *choice #Red. You prefer a red horse! *finish #Green. You prefer a green horse! *finish *label DonkeyColor What color do you want your donkey to be? *choice #Red. You prefer a red donkey! *finish #Green. You prefer a green donkey! *finish
It is particularly worth noting that the *label name being referenced by a *goto command can be anywhere else within the same scene file, either above or below the actual *goto command. For example, the following will work just fine:
*label Donkey What color do you want your donkey to be? *choice #Red. You prefer a red donkey! *finish #Green. You prefer a green donkey! *finish *label Horse What color do you want your horse to be? *choice #Red. You prefer a red horse! *finish #Green. You prefer a green horse! *finish What do you prefer? *choice #A donkey. You prefer a donkey! *goto Donkey #A horse. You prefer a horse! *goto Horse
The only important thing to remember is that all *label names within a single file must be unique.
More commands / functions | |
Choice | *choice, *fake_choice, *disable_reuse, *hide_reuse, *allow_reuse, *selectable_if |
---|---|
Variable | *create, *temp, *set, Arithmetic operators, *delete, *input_number, *input_text, *print, *rand |
Conditional | *if, *elseif, *else, Multireplace |
Goto | *label, *goto, *goto_scene, *goto_random_scene, *gosub, *gosub_scene, *finish |
Formatting | Bold text, Italic text, *image, *line_break, *page_break, *link, *stat_chart |
Miscellaneous | *comment, *scene_list, *title, *author, *achieve, *achievement, *check_achievements, *bug, *ending, *more_games, *share_this_game, *show_password, *script, Implicit Control Flow |