# Variables
TIP
To define a variable, all you need to do is type the variable name, then put an equal sign ( = ) then put the expression or calculation after it. The predefined variables listed below can be used; but cannot be overridden!
# Predefined variables
$args$ The arguments passed to the command by the player
$player$ The player name thats running the command
$world$ The world the player is in
$x$ X coordinate of the player
$y$ Y coordinate of the player
$z$ Z coordinate of the player
$yaw$ The players yaw
$pitch$ The players pitch
$health$ The players health (0 - 20)
$food$ The players food (0 - 20)
$time$ The time in seconds and milliseconds from 0:00:00 January 1, 1970, GMT
$true$ Boolean true
$false$ Boolean false
$null$ null
# Global Variables
You can define variables globally, which means that these variables will be defined for as long as the server is online, and they can be used in any command without the need of redefining them, you can do that exactly the same way you define a normal variable, but the difference is you add global behind it, so it would look like this:
global $variable$ = <expression>
And to use the variable, it's also same as using a normal variable, but you'll need to add global behind it, for example:
sendMessage($player$, global $variable$)
# Example
1: $testVariable$ = 'Hello there!'
2: $final$ = $testVariable$ + ' ' + $player$ + ' is in the world: ' + $world$
3: sendMessage($player$, $final$)
4: global $target$ = $player$
5: # The line above will set the variable $target$ globally, and now it can be used in any command without the need of defining it again.