Functions
Updated 30 Mar 2026String functions
All string functions accept a string as the first argument and return a value usable in any expression.
| Function | Returns | Description |
|---|---|---|
len(str) | number | Length of the string |
upper(str) | string | Convert to upper-case |
lower(str) | string | Convert to lower-case |
trim(str) | string | Remove leading/trailing whitespace |
substr(str, start) | string | Substring from index |
substr(str, start, end) | string | Substring between indices |
replace(str, old, new) | string | Replace all occurrences |
contains(str, search) | boolean | True if str contains search |
startswith(str, prefix) | boolean | True if str starts with prefix |
endswith(str, suffix) | boolean | True if str ends with suffix |
split(str, delim, index) | string | Split by delimiter, return element at index (0-based) |
indexof(str, search) | number | Index of search in str, or -1 if not found |
set $msg = "Hello, World!"
send len($msg) to player
send upper($msg) to player
set $first = split($msg, ",", 0)
set $pos = indexof($msg, "World")
Math functions
| Function | Returns | Description |
|---|---|---|
abs(n) | number | Absolute value |
floor(n) | integer | Round down |
ceil(n) | integer | Round up |
round(n) | integer | Round to nearest |
min(a, b) | number | Smaller of two values |
max(a, b) | number | Larger of two values |
sqrt(n) | number | Square root |
pow(base, exp) | number | Exponentiation |
random(lo, hi) | integer | Random integer in range (inclusive) |
set $r = random(1, 100)
set $hp = round(player.health)
send "HP: $hp / 20" to player
Utility functions
| Function | Returns | Description |
|---|---|---|
isnumber(value) | boolean | True if value can be parsed as a number |
format(number, decimals) | string | Format number with N decimal places |
command /pay:
if isnumber($arg1) == false:
send "&cUsage: /pay <amount>" to player
return
set $label = format($arg1, 2)
send "&6Amount: &e$label coins" to playeronline()
Return the number of players currently online.
set $count = online()
send "There are $count players online." to player
world()
Return the name of the player's current world.
set $w = world()
send "You are in: $w" to player
hasPermission(node)
Return true if the player has the given permission node, false otherwise.
if hasPermission("myserver.vip") == true:
send "&6Welcome, VIP!" to player
else:
send "&7Hello, player." to playerhealth()
Return the player's current health (0 – 20).
set $hp = health()
send "Your health: $hp / 20" to player
food()
Return the player's current food level (0 – 20).
set $hunger = food()
if $hunger < 10:
send "&cYou are hungry!" to player
nearby(radius)
Return the count of players within radius blocks.
set $count = nearby(20)
send "Players within 20 blocks: $count" to playerlevel()
Return the player's current XP level.
set $lv = level()
send "You are level $lv" to player
gamemode()
Return the player's game mode as a lowercase string (survival, creative, etc.).
set $gm = gamemode()
if $gm == "creative":
send "&bCreative mode active" to player
formattime(seconds)
Convert seconds into a readable string like 1h 5m 30s.
set $pretty = formattime(3750)
send "Time: $pretty" to player
isop()
Return true if the player is a server operator.
if isop() == true:
send "&c[OP] You have operator privileges." to playerx()
Return the player's current block X coordinate.
set $px = x()
send "Your X position is $px" to player
y()
Return the player's current block Y coordinate.
set $py = y()
if $py < 0:
send "&cYou are in the deep dark!" to player
z()
Return the player's current block Z coordinate.
command /coords:
set $cx = x()
set $cy = y()
set $cz = z()
send "&aCoords: X=$cx Y=$cy Z=$cz" to player