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. Variable name must always start with a letter and must only contain letters, numbers and _.

Global Variables #

All global variables are stored inside global variables object and are accessible from any button at all times. Some of these variables are permanent.
Use Get Global Variable command to get a global variable and Set Global Variable command to set a new or update an existing global variable.
Do not pollute global namespace unless you absolutely have to. It’s almost always better to use either local or button variables.

Button Variables #

Button variables are stored inside every button object. They can be accessed from any other button (if their own button is set to persistent) by using Get Button Variable command and created or updated by using Set Button Variable command.

Local Variables #

Local variables are button’s own variables that can be directly accessed from its own button at anytime (even if the button is set to non persistent). This is what you want to use 99% of the time.
Using Set String Variable command lets you set a local variable containing text.

Persistent vs. non persistent variables #

By going to your Button Settings, you can decide whether you want your local variables to persist or not for the given button.
If you check the box, it means the variables will be accessible even after the button has finished. If Allow Button Overlap is enabled, all button executions will share the same variables.
If you uncheck the box, the variables will be accessible only when the button is running and only inside their own button. Other buttons cannot access them even if the button is currently running. If Allow Button Overlap is enabled, unique variables will be created for each button execution and will never be shared.

Init Variables #

If you right click on a button, you can edit its INIT variables.
These exist to prevent crashes if you have enabled persistent variables.
The window uses a simple JSON format to initialize your variables.
For example, if you want your variable name to have a value of LioranBoard and your variable age to have a value of 18 on initilization, you can do:

{
	"name": "LioranBoard",
	"age": 18,
}

You can also initiliaze complex variables, such as arrays or objects:

{
	"namesArray": ["Lioran", "Melonax", "Cyanidesugar"],
	"colorObject": {
		"Lioran": "blue",
		"Melonax": "purple",
		"Cyanidesugar": "red "
	}

}

Variable types #

Variable Type Example Color in variable window
Real value (number) 50 green
String (text) "My Cat" or 'My Cat' blue
Boolean 1 = true, 0 = false cyan
Array ["cat","rabbit","dog"] yellow
Object {"name": John, "age": 25, "country": Canada"} purple
Undefined Variable does not exist/is set to empty value red
Null Variable with empty or non existent reference red

Real value (number)

Variable containing numbers only. Negative values, decimal points and Euler’s numbers are allowed.
Examples: 50, 1.25, -15, 10e+2

String (text)

Variable that contains not just numbers, but also other characters (possibly mixed with numbers).
If you are inserting a string into a YELLOW variable box, you must wrap it in double or single quotes.
Note that a string containing only numbers is not regarded as a number and cannot be used as such. You must use ‘String to Number’ command to convert to number first.
Examples: "Hello world!", 'This is cool', "The tickets cost $50", '50' (still regarded as a string!)

Boolean

In LioranBoard, boolean is a number that is either 0 (false) or 1 (true).\

Array

Array is a special variable which can hold more than one value at a time. Learn more about arrays in our Array Introduction section.

Object

Object is another special variables which can hold more than one value at a time. Unlike arrays, objects have named values, key-value pairs. Learn more about objects in our Object Introduction section.

White vs. Yellow Box for parameters #

When you start using commands in LioranBoard, you will notice that some parameter boxes have yellow color and some have white color.

Different parameter box colors
Different parameter box colors

It’s extremely important to know the difference as you need to format your input according to the color of the box.

Operation White Box Yellow Box
Inserting another variable You must wrap other variables in /$$/.
/$myVariable$/
You can directly type another variable.
myVariable
Inserting array value You must wrap them in /$$/.
/$myArray[0]$/
You can directly insert them.
myArray[0]
Inserting real values (numbers) You can directly insert them.
26
You can directly insert them.
26
Inserting string values (text) You can directly insert them, such as Hello World and even use new lines by pressing ENTER You have to wrap any string in double/single quotes.
"Hello World" or 'Hello World'
Using a combination of strings and variables You can insert a variable into text by wrapping it in /$$/.
Hello world, this is my /$myVariable$/, isn't it cool?
You must wrap any string in double/single quotes and use + to combine them with other variables. The whole value must be enclosed in parentheses.
( "Hello World, this is my " + myVariable + ", isn't this cool?" )
Math Operations All math operations must be enclosed in /$$/ and parentheses.
Hello world, do you know what's 3+7? It's /$(3+7)$/!
All math operations must be enclosed in parentheses.
( "Hello world, do you know what's 2+7? It's " + (2 + 7) + "!" )


Edit

Set Local Variable #

Creates a new local variable or modifies an existing one.
Local variables are contained in the button that created them. They can be accessed from other buttons by using Set/Get Button Variable (as long as the button has persistent variables enabled).

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

Advanced Users
You can use this command to create and modify all variables, including global and button variables, object keys and array items. Lots of commands in LioranBoard are redundant and rather targeted at users with no coding knowledge.
Global variables: Use global. prefix, since they’re all stored in an object called global.
Button variables: Use buttonID. prefix, since they’re all stored in an object named after the button ID.
Array Values: Use myArray[index] to change a value inside an array.
Object Keys: Use myObject.key to change a key inside an object.
You can access nested objects and arrays by using dot notation, it works the same just like in JavaScript. Bracket notation does not work, you must use Set/Get Object Variable command for keys containing spaces or dashes.


Edit

Set String Variable #

Creates a new local variable containing text.
Checking relative will cause it to do string addition. I.e. if a variable myVariable already exists and contains Hello and you enter World in the Text field, myVariable will be now Hello World.

Box Name Type Description
Variable Name String Name of the variable.
Relative Checkbox Checked = will be turned into string addition, Unchecked = replaces whatever is currently in the original variable if already populated
Text String Whatever text you want to set the variable to. You can press ENTER to insert a new line.


Edit

Set Button Variable #

Creates a new button variable or modifies an existing one.\ Button variables are other buttons local variables. You cannot set a button variable for a button that has persistent variables disabled, this will crash LioranBoard.

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


Edit

Set Global Variable #

Creates a new global variable or modifies an existing one. Global variables are persistent and always accessible by all the buttons. Try to avoid creating them unless absolutely necessary to avoid polluting the global namespace.

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


Edit

Set Boolean #

Allows you to set a boolean variable.
In LioranBoard, boolean is a number that is either 0 (false) or 1 (true).

Box Name Type Description
Variable Name String Name of the variable to save the boolean value.
Boolean Boolean Boolean value you want to set the variable to. Will be converted to true or false.


Edit

Get Button Variable #

Gets another button’s variable. The button must have persistent variables enabled, else no other button can access them even if the button is running.

Box Name Type Description
Button ID String The button you want to set the variable for.
Get Variable String Name of the variable to get.
Save Variable String New local variable name to save the button variable.


Edit

Get Global Variable #

Gets global variable.

Box Name Type Description
Button ID String The button you want to set the variable for.
Get Variable String Name of the variable to get.
Save Variable String New local variable name to save the button variable.

There are several premade permanent global variables that might be useful for your commands:

Variable Explanation
transmitter_connected true if connected, false if not connected
twitch_chat_connected true if connected, false if not connected
twitch_client_id LioranBoard Twitch Client ID, used in Twitch API calls
main_directory Main directory where LioranBoard folder resides. Useful for extension makers to be able to easily copy files.
Architecture Type of architecture you’re on. x64 or x86.
elapsed_time Elapsed time in seconds since you last started LioranBoard
since_2020 Elapsed time in seconds since January 1st, 2020.
mouse_x Current x position of your mouse
mouse_y Current y position of your mouse
twitch_accounts array of all linked Twitch account login names
Main An object containing information about your main OBS connection.
Main.connected Whether LioranBoard is currently connected to your main OBS, true = connected, false = disconnected
Main.current_scene Current scene in your main OBS
Main.previous_scene Previous scene in your main OBS


Edit

Get Variable Type #

Returns a string indicating the type of the variable:

  • "number" for numbers
  • "string" for variables containing text
  • "object" for objects
  • "array" for arrays
  • "boolean" for boolean values
  • "undefined" for variables that aren’t defined (do not exist)
  • "null" for null variables (sometimes retrieved from HTTP requests, cannot be manually created)
Box Name Type Description
Variable (Save) String Variable to save the result in.
Variable (look at) String The variable to get the type of.


Edit

Variable Transition #

Transitions a variable (number) from a starting value to a final value over a given duration.
This command can act as a timer to trigger other commands or buttons.
For example, if you set the start value to 10, final value to 0 and duration to 10000ms (=10 seconds), it will decrease the value by 1 every second and reach 0 after exactly 10 seconds.

Box Name Type Description
Variable Name String Name of the variable.
Start Value Number Starting point (where the counting starts from)
End Value Number Finishing point (where the counting stops at)
Allow Decimal Checkbox Whether you want to allow values with decimal points
Duration(ms) Int Duration of the transition
Smooth Dropdown None = Normal, Out = Starts out fast and ends slow, In = Starts out slow and ends fast, In/Out= Starts out slow, gets faster and then slows down at the end again.


Edit

Delete Variable #

Deletes an existing variable.
You can use dot notation for deleting button variables (buttonID.myVariable), global variables (global.myVariable), object keys (myObject.key). Will clear ALL the button variables if you put the button ID into the variable field.

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