Variables

In Kocho, **variables** are used to store **values.** Variables and values are crucial to creating choices and routes. Some features may not work without the use of variables.

## Overview

Variables are stored in the Variables tab inside of every project. They can be created and edited there, but their values can only be changed through playing the visual novel they are in.

Values can be altered in two ways:

1. Presetting a variable to a specific value before previewing a scene, and
2. Selecting choices or interactive areas within the visual novel.

Option 1 is simple and concise, so we'll discuss option 2 instead.

### Choice Operators

Choices and interactive areas alter the value of a variable via the use of **Choice Operators.** Choice Operators are functions that dictate how a value will be altered.

* The = symbol overrides the current value of the target variable to equal a fixed amount.
* The + symbol increases the current value of the target variable by a fixed amount.
* The - symbol decreases the current value of the target variable by a fixed amount.
* The \* symbol multiplies the current value of the target variable by a fixed amount.
* The / symbol divides the current value of the target variable by a fixed amount.

### Conditional Operators

Routes can be created through the use of **Conditional Operators.** Conditional Operators are functions that dictate what value a variable must be for an action to play.

* The = symbol indicates the value of a variable must be equal to a fixed amount.
* The <> symbol indicates the value of a variable must not be equal to a fixed amount.
* The > symbol indicates the value of a variable must be greater than a fixed amount.
* The < symbol indicates the value of a variable must be less than a fixed amount.
* The >= symbol indicates the value of a variable must be greater than or equal to a fixed amount.
* The <= symbol indicates the value of a variable must be less than or equal to a fixed amount.

## Tutorials

We will go over how to use Choice Operators and Conditional Operators below.

### Using Choice Operators

To alter a variable's value through a choice or interactive area:

1. Create or select a choice action or interactive area action.
2. Press the three dots next to the action.
3. Press "Edit".
4. Select or create a choice/interactive area.
5. (For choices) Input a message for the choice.
6. Press "Select a variable" and select a variable. If you have not created one yet, create one and name it.
7. Select a Choice Operator.
8. Input a value by which the value of the variable will be altered.
9. Select "Add Variable".
10. Repeat steps 4-9 as many times as you need.
11. Select "Add Action".
12. Repeat steps 1-11 as many times as you need.

### Using Conditional Operators

To make routes that are dependent on the value of a variable or variables:

1. Create or select any chapter, scene, or action.
2. Press the three dots next to it.
3. Press "Conditions".
4. Press "Select a variable" and select a variable. If you have not created one yet, create one and name it.
5. Select a Conditional Operator.
6. Input a value by which it and the value of the variable will result in a true statement.
7. Repeat steps 4-6 as many times as you need.
8. Select "Add Condition".
9. Repeat steps 1-8 as many times as you need.

## Trivia

* "Choice Operators" and "Conditional Operators" are called arithmetic operators and comparison operators in computer science respectively,
* As of now, you cannot input non-integer values as fixed values for Choice Operators nor Conditional Operators.
	+ That being said, Kocho will not crash if the value of a variable becomes a non-integer, or if the value is divided by zero. Instead, the value of the variable will be labeled as the appropriate mathematical value for the former and as "Infinity" for the latter.
* When previewing a scene, variable values from previous scenes do not apply; the playtester must instead input a specific value for the variable to be. (This is what Option 1 in the Overview section is.)