This page will teach you some things about variables.
What is a variable
A variable is a value that holds data like states or numbers or even words for later use. They are useful when needing to test if something is happening or if a word is the same as something else, they can also be used in math to test for number values.
There are three kinds of variables, Logic, String, and Numbers. Each type holds specific types of data.
- Logic: Stores true or false data to blocks, worlds or maps. The real term for this kind of a variable is a boolean.
- String: Stores text data to blocks, worlds or maps. The real term for this kind of a variable is actually a string.
- Number: Stores solid or decimal numbers data to blocks, world or maps. The real term for this kind of a variable is an integer.
Global variables save variable data to dimensions or entire maps or only run during a session. Below lists each global variable type and some of the key features each one has to offer.
- Global session: Sets a variable to all worlds, main screen, and menus, but does not save them.
- Global world: Sets and saves a variable to a dimension.
- Global map: Sets and saves a variable to the entire map.
Local variables can be used in mod elements are store the variable locally within that element. They use all three variable types listed above.
NBT are variable types like local entities however rather than having a worldwide variable set per element you can target a specific block, item or entity to have a variable stored in them.
Variables explained in a video
If you prefer to watch the video, you can find the wiki page above summarized in videos below: