Functions

Add dynamic content into your presets

Usage

Format

All functions follow the following format. Arguments can also be wrapped in quotes.

$function(arg1, "arg2")

Most functions can also be nested inside eachother, creating more complex behaviour. This is the main advantage of functions over placeholders.

$uppercase($var("pet_name")) // Cat -> CAT

New functions can also be added with addons using plugin API.

Default Functions

$data(key)

Get data from the current preset file. See how to define data in presets.

# EXAMPLE DATA
data:
    key: 10
    prices:
        sword: 100
        chair: 50
    lines:
    - 'Hello!'
    - 'How are you?'
// Returns the value from data.key
$data(key) // 10

// Returns the value from data.prices.sword
$data(prices.sword) // 100

// Returns the price from data.prices.<furniture_id>
$data(prices.$context(furniture.id)) // 50 if chair

// Returns the 0 indexed element in list "lines"
$data(lines[0]) // Hello

// Returns the length (size) of a list
$data(lines[length] // 2

$hasdata(key)

Same as data, but returns true if given path exists and false if not.

$hasdata(key) // true

$hasdata(fakekey) // false

$context(key)

Get a given key from condition context. In order for context to exist, the preset has to have this condition in its conditions. $context(key) can use similar keys to the data function. See which conditions return context. (By default, all conditions also return a condition.<condition> context, which has the result of the condition (true/false) )

// true if "sneaking" condition is true 
$context(condition.sneaking)

// true if "op" condition is true
$context(condition.op)

// world name if "world" condition is true
$context(world)

// get first element from a context
$context(list[0])

$hascontext(key)

Same as $context(key), but returns true if context is set and false if not.

// returns true if world context has been set
$hascontext(world)

$if(condition, trueText, falseText)

Conditional function, which takes an evaluated statement and depending on the output displays either trueText or falseText.

// returns the text "True!"
$if(true, "True!", "False...")

// returns "You're opped!" if player is opped
$if($context(condition.op), "You're opped!", "You're not opped")

$var(global, key) $pvar(global, key)

Variable functions allow to retrieve values from variables using a key. $var is used for local variables and $pvar is used for persistent (saved) variables.

// returns the value of the "busy" variable for current player, for ex. true
$var("busy")
// same as above, but persistent
$pvar("busy")

// returns the global and persistent "purchases" variable, for ex. 10
$pvar("global", "purchases")

$parse(player, text)

Parses the given text for another player, instead of the player viewing the tooltip.

// returns "Septicuss"
$parse("Septicuss", "%player_name%")

// returns the Vault balance of the target player
$parse($context("lookingatplayer.name", %vault_eco_balance%)

String functions

$lowercase("HEY") // -> "hey"
$uppercase("hey") // -> "HEY"
$capitalize("hey") // -> "Hey"

$static(text)

An important optimization function, which processes and caches the text within. This will stop the given text from being updated and will stay static.

// will display the value of the "busy" variable
$static($var("busy"))

$strip(text)

Strips the given text from all animation tags. Useful when text has to be displayed in another tooltip after an animation was done.

// returns "Hello!"
$strip("<tw t=Hello!>")

$preprocess(text)

Needed when importing text from elsewhere (for example using a placeholder or a function), which has animations.

// processes the animations of the first line defined in data
$preprocess($data(lines[0]))

Can think of some other useful function? Suggest it in the Discord!

Last updated