Switch

Introduction

Switches offer a method of saving a boolean (true or false, yes or no) to memory. They can be used to save toggles, such as if a menu is open, a character is present, and so forth.

Contexts

Contextually, switches are supported globally and locally.

Local

Local contexts are generated for an individual instance. Local instances are usually setup on their respective containers and only exist while that container is active. If the container is no longer in play, the local data is removed.

Example: Entities? support local variables and switches. If you were creating an action battle system, it would be possible to track whether the entity is alive or not by a local switch. Copying and pasting the same entity over and over again would then allow each entity to have their own local switches that were unaffected by others, essentially creating a prefabricated enemy.

Global

Global contexts exist throughout an instance of a game, regardless of where they exist. This is the default way switches are implemented in most engines.