Variables

As a miscellaneous tool, this plugin supports internal variables. These variables can be set inside actions or through a command by admins and then used to check conditions inside tooltips.

Variables have a target, persistence and are defined through key-value pairs. For example, you can have a variable named "meow" equal to "true" or "amount" equal to 5.

Usage

Below is a reference table, which shows where and how variables can be used;

If you want to modify variables, you can do it:

conditions:
  conditions:
  # When looking at a bedrock block
  - lookingatblock{type=bedrock} true
  actions:
    right-click:
    # And right clicking that bedrock block, set players variable "cool" to "true"
    - setvar %player% cool true
  • Externally (outside of actions), using the vars command For example: /tt vars setvar Septicuss cool true

If you want to use variables in conditions (to check something)

conditions:
  conditions:
  # Check if player has variable "cool" set to true
  - compare{ first=%var_cool%; second=true }

If you want to use variables in tooltips text

content:
  text:
  - 'Is the player viewing'
  - 'this tooltip cool?'
  - '%var_cool%'

If you want to display variables outside of Tooltips in other plugins

Terminology

Persistence

There are persistent and non-persistent variables. Persistence means that variables are saved into files and kept around. Non-persistent variables are reset on server restart, persistent variables can only be cleared through the proper commands.

Scope

Variable commands define a scope, which defines who this variable will be set for.

Evaluation

Setting the variable supports mathematical expressions, which can utilize PAPI placeholders and local placeholders. Examples:

setvar player myvariable (1+1)
setvar global goofballs %var_global_goofballs% + 1
setvar global goofballs (%var_global_goofballs% / %mvar_myvariable%) * 30 + 25
/tt setpersistentvar Septicuss personal_number 31*5

PlaceholderAPI

Using PlaceholderAPI placeholders has been made as simple as possible. Placeholders are dynamic, and you have to build them using keys:

Structure of a placeholder

%tooltips_[KEY]_[ID]%

[KEY] -> multiple keys combined in any order

[ID] -> ID of the variable being requested

Examples

Get the player variable "cool"

%tooltips_v_cool%

Get the global variable "cool"

%tooltips_gv_cool%

Get the persistent player variable "tutorial_passed"

%tooltips_pv_tutorial_passed%

Get the persistent global variable "views"

%tooltips_pgv_views%

Last updated