Skip to content
JasperLorelai edited this page Jul 16, 2023 · 18 revisions

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, UpperCamelCase or snake_case format. (Example: meta_location_x)

General Configuration:

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

BossBar configuration:

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:

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).


Variable Types:

global type

  • The global variable type has no defined owner. If you're modifying it through the ms variable modify command, 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

player type

The player variable type is bound to players. All other properties of this variable type are shared with the global variable type.


globalstring type

  • The globalstring variable type is a global type too - with no defined owner. When using the ms variable modify, use - as the <player> argument.
  • The Java variable type of this variable is String.
  • This variable type only has the default-value property.

playerstring type

The playerstring is player-bound. All other properties are shared with the globalstring variable type.


distancetolocation 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

squareddistancetolocation type

Clone this wiki locally