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:
Inside tooltips' actions, using variable commands For example:
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)
Use the compare condition with variable functions For example:
If you want to use variables in tooltips text
Use the variable functions For example:
If you want to display variables outside of Tooltips in other plugins
Use PlaceholderAPI variable placeholders For example:
/papi parse Septicuss %tooltips_v_cool%
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.
Global
A global variable applied to all players.
Player
The current player. For example, if this scope is used in actions, the action command will be executed for the player with an active tooltip.
<Player_Name>
An online players name. Using this will set it only for a specific player.
Evaluation
Setting the variable supports mathematical expressions, which can utilize PAPI placeholders and local placeholders. Examples:
PlaceholderAPI
Using PlaceholderAPI placeholders has been made as simple as possible. Placeholders are dynamic, and you have to build them using keys:
v
variable (always required)
g
global
p
persistent
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