-
Notifications
You must be signed in to change notification settings - Fork 71
Variables
Description: In MagicSpells, you can use variables to store information. Variables are defined by their name and the type of information they contain.
Variables can be defined in the general.yml file or any spell file. The main configuration looks like this:
variables:
varName:
# (Variable configuration)The variable name (varName) should follow a naming convention:
- The name should be meaningful in indicating its use.
- It should not start with numbers or symbols, but a letter.
- It should not contain certain special characters to avoid systems processing the variable name assuming that the special character is some sort of operation. For instance, if the name contains
-, something might assume that you're trying to do subtraction. - It should follow
lowerCamelCase,UpperCamelCaseorsnake_caseformat. (Example:meta_location_x)
| Option | Description | Variable Type | Default Value |
|---|---|---|---|
type |
Defines the information the variable can contain. Valid types: global, player, globalstring, playerstring, distancetolocation, and squareddistancetolocation. |
String | global |
permanent |
Defines if this variable's value should be saved during reloads/restarts. | Boolean | true |
scoreboard-title |
If not defined, this feature will remain being disabled. The scoreboard feature only works for player type variables. Now supports color codes. |
String | "" |
scoreboard-position |
Defines the position of the scoreboard display. Valid positions: sidebar, nameplate, or playerlist. |
String | "" |
exp-bar |
Defines whether to display this variable on the experience bar. This does not modify the real experience. The feature only works for global and player variable types. |
Boolean | false |
boss-bar |
If anything is defined here, the variable value will be displayed as the progress of a boss bar. This can be a boss bar title (string), or a BossBar configuration section (map). | String or Section | null |
| Option | Description | Variable Type | Default Value |
|---|---|---|---|
title |
Defines the title of the boss bar. | String | "" |
style |
Defines the boss bar style. | String | "solid" |
color |
Defines the boss bar color. | String | "purple" |
namespace-key |
Defines the Namespace Key of this boss bar. If this is unique, this boss bar will display separately. | String | "ms_variable" |
Meta variables are special variables that help you access or modify special data regarding an entity, player, server, or other. An example is getting the server's player count, setting a player's compass target location, etc. A list of these variables can be found here, but note that they have to start with meta_ (e.g. meta_location_x).
- The
globalvariable type has no defined owner. If you're modifying it through thems variable modifycommand, you can specify the<player>parameter as-or any string which isn't a valid player name. - The Java variable type of this variable is Double.
| Option | Description | Variable Type | Default Value |
|---|---|---|---|
default |
Defines the default variable value. | Double | 0 |
min |
Defines min bounds. | Double | 0 |
max |
Defines max bounds. | Double | Double.MAX_VALUE |
The player variable type is bound to players. All other properties of this variable type are shared with the global variable type.
- The
globalstringvariable type is a global type too - with no defined owner. When using thems variable modify, use-as the<player>argument. - The Java variable type of this variable is String.
- This variable type only has the
default-valueproperty.
The playerstring is player-bound. All other properties are shared with the globalstring variable type.
- This variable cannot be modified. It returns distance calculated by the defined configuration.
- The Java variable type of this variable is String.
| Option | Description | Variable Type | Default Value |
|---|---|---|---|
default |
Defines the default value to return if something failed. | Double | 0 |
cross-world |
Defines whether the distance can be calculated across worlds. | Boolean | false |
target-location |
Define location to calculate distance from. Format: world,x,y,z. |
String | world,0,0,0 |
cross-world-distance-multiplier |
Defines cross-world multiplier. | Double | 1 |
- The
squareddistancetolocationvariable type shares the same properties as thedistancetolocationvariable type, but the result is distance squared.