Variables

Edit

Introduction #

Variables are containers for storing data values (including numbers and strings), that can be reused over and over again.
Variable names are case sensitive, meaning that “Variable” and “variable” are not going to have the same value.

Value of a variable can be:

  • Another variable - myVariable or /$myVariable$/
  • Real value (number) - 50
  • String - "My Cat"
  • Stack value [index]stackname - [2]myStack
  • Math expression including variables and Complex Math operators. Must be wrapped in (). - (myVariable * 10 - [2]myStack + 3)

All variables inside Receiver are global and get deleted every time you close or reset Receiver.
Variables are not unique to a button that created them and any button/deck can access them.


Edit

Math: Change Variable #

Creates a new variable or modifies an existing one.

Box Name Type Description
Variable String Name of the variable.
Operator Dropdown Operator you wish to use on the value.
Value Any Whatever you want to set the variable value to. Can contain complex math.

Examples of usage #

The table containing examples below assumes we have the following variables and stack:

Green marks a good example and red marks a bad example.
Bad examples can result in LB crashing. Click on the for explanation.
var = variable, str = string

Input Variable type operator Input Value type Output Variable Output Value type
_variable var = “Hello World” str _variable “Hello World” str
1variable var = “Hello World” str 1variable “Hello World” str
user str = “Melonax” str user “Melonax” str
user str = Melonax real user 0
points str = 50 real points 50 real
points str = “50” str points “50” str
points var += 100 real points 150 real
points var += “100” str Execution Error
name str = user var name “Melonax” str
name str = /$user$/ var name “Melonax” str
/$user$/ var = points var Melonax 50 real
user var?? = points var user 50 real
Sebas_points str = (/$points$/+30 + /$points$/*3) var+real Sebas_points 230 real
Sebas_points str = /$points$/+30 + /$points$/*3 var+real Sebas_points 50 real
winner str = [0]users stack value winner “Lioran” str
winner str = users[0] stack value winner 0 real
/$[1]users$/_color var+str = “red” str Melonax_color “red” str
[1]users_color var??+str = “red” str [1]users_color “red” str
/$[3-position]users$/
var+real as stack position
= “cool streamer”str Melonax “cool streamer” str
/$[3-/$position$/]users$/
var+real as stack position
= “cool streamer”str 0]users$/ “cool streamer” str
user = [round(/$[3]users$/*0.6)]users
real+stack value as stack position
user “Melonax” str
user = [round /$[3]users$/*0.6]users
real+stack value as stack position
user “Lioran” str
winner str = [position]/$stack_name$/
var as stack value+var as stack name
winner “Lioran” str
winner str = [position]stack_name
var as stack value+var as stack name??
winner 0 real
all_users = ”/$[0]users$/,/$[1]users$/,/$[2]users$/”
var as stack value + str
all_users “Lioran, Melonax, Sebas” str
all_users = /$[0]users$/,/$[1]users$/,/$[2]users$/
var as stack value + str
all_users 0 real
chat_message = “User /$[0]users$/ has /$points$/ points.”
str+stack value+var
chat_message “User Lioran has 50 points.” str
chat_message = “User [0]users has /$points$/ points.”
str+stack value+var
chat_message “User [0]users has 50 points.” str


Edit

Math: Clear Variable #

Clears a single variable. It removes it from the list of variables as well (accessible from the main menu by pressing TAB).
Useful command to keep your variable list clean and organized.

Box Name Type Description
Variable String Name of the variable to clear.


Edit

Math: Get Variable Type #

Returns a string indicating the type of the variable:

  • "number" for numbers
  • "string" for variables containing text
  • "undefined" for variables that aren’t defined (do not exist)
Box Name Type Description
Variable Name String The variable to get the type of.
Variable Save String Variable to save the result in.