The *goto_scene command is used in the same general manner as an ordinary *goto, but instead of a label name reference within the same scene file, it requires a specific scene name to load; this being a particular .txt file in your "scenes" (..\mygame\scenes) folder. *goto_scene can load any scene file, whether or not that file is included in the *scene_list section of startup.txt.
*goto_scene is one of two very different commands enabling the proper use of multiple different scene .txt files in your game (thereby essentially making it unlimited in scope and size); the other being the *finish command.
There are some key differences between *goto_scene and *finish:
- *goto_scene allows you to jump to any scene in the scenes folder, whereas *finish only loads the next sequential scene in the startup.txt *scene_list.
- using *goto_scene, you can specify where in the called scene you wish to go by adding the name of a label in that scene.
*goto_scene is typically used as follows:
Where do you want to go? *choice #To the park. You decide to go to the park. *page_break End of Scene *goto_scene park #Home. You decide to go home. *page_break End of Scene *goto_scene home #To the City Hall. You decide to go to City Hall. *page_break End of Scene *goto_scene cityhall
The scene referenced with a *goto_scene command must exist in the scenes folder. For example, for the above code to work properly, in the scenes folder for this game the following files must be present:
To go to a specific *label in the called scene, you can write:
*goto_scene [scene file] [label]
For instance, if the "home.txt" file contains several *labels, one of which is called "Fire", you can jump to that section of that scene by typing:
*goto_scene home fire
This will skip any content in the home.txt scene before the "fire" label.
It is worth bearing in mind that any *temp variables (and their current values) created in the current scene file will be lost from memory the instant that a new scene file is loaded using the *goto_scene command. Where this may cause continuity problems in your story / scripting, you should instead define those variables using the *create command in startup.txt.
[Advanced Scene Scripting Notes] Scenes & startup.txt
Scenes intended to be loaded sequentially, using the *finish command, must be included in the *scene_list section of the startup.txt file located in the "scenes" (..\web\mygame\scenes) folder. However, if you only ever direct the scene file loading using the specific *goto_scene [scene name] command, only your very first, opening scene file need be listed in the *scene_list, as its only purpose is to direct a *finish command.
Note also that you should never use *goto_scene to return to startup.txt from another scene file without also referencing a specific *label to jump to. Doing so will cause ChoiceScript to reset all permanent variables back to their original default values (i.e. on loading it effectively reruns the entire list of *create commands present in that file). Referencing a specific *label in startup.txt, somewhere below all the *create commands, will however avoid this problem.
|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|
|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|