Learning ChoiceScript: Part 8: Labels and Subrountines

Learning ChoiceScript

ChoiceScript is a scripting language from Choice of Games LLC for creating choose-you-own-adventure games.


 

Labels

While the *goto_scene command can direct the player to another scene, there is other functionality that can reduce the dependence on using different files and help with better organizing code: labels.

Screenshot 2018-08-26 12.50.41

Using the *label command tells ChoiceScript to create a small section of code that can be visited like a sub-scene.

Screenshot 2018-08-26 12.51.32

Going to a scene is similar to using the command *goto_scene but references the scene and the label.

Label

 

Subroutines

Working like labels, subroutines are designed for doing a small, function-like task and then returning to the original place.

Screenshot 2018-08-26 13.01.43

Using the *label command, they are defined just like other labels but use the additional command *return.

Screenshot 2018-08-26 13.04.38

Subroutines are used through the *gosub command and then the name of the label.

Subs

GitHub Gist Version: