Quillscript Variables
A variable is a named location in memory that holds a value.
To declare a Quillscript variable, type the desired name, and use the = (Assignment Operator) to assign a value.
Once assigned, you can use this data everywhere in your script and even in your Blueprint/C++ code.
Variable Type
Quillscript is an inferred type language, meaning that the variable type is automatically deduced. There are three variable types: Switch, Number, and Text. The variable type is used to determine the behavior of this variable for each operator, a Number type variable can be used for math operations, for example.
Switch
Represents an on/off state, also known as Boolean.
Number
For numeric values. Integers and floating points.
Text
For string values.
Variable Access
The variable mark describes how Quillscript interpreter handles its lifecycle and other automatized tasks.
Global
By default, any Quillscript variable is global. Once created, a global variable can be used in any other script, allowing script intercommunication.
Use global variables when persistence or intercommunication is necessary, and use temporary variables otherwise, since persistent variables take memory space, increase save file size, and increase the duration of certain tasks, like variable replacement in texts and expressions.
Temporary Variables
A Temporary Variable is a Quillscript variable that only exists during that script play. Temporary variables are automatically deleted when the script ends.
These variables are the preferred method for declaring variables when they don't need to exist after a script play. The use of these variables saves computing resources, since Quillscript has a smaller list of variables to search and apply tasks.
To declare a Temporary Variable, you name it starting with : (colons).
Outer Variables
Quillscript creates these variables to capture the return value of called functions. They have the same lifecycle of temporary variables and are deleted when the script ends. Check Function Call section for more details.
Template Variables
These variables are created by Quillscript to be used as arguments by a template call. They are deleted when a label statement is reached. Check Template section for more details.
Assigning Variables
Besides assigning static hard-coded values, variables also accept math expressions and other value concatenation methods.
Expressions
You can assign a complete math expression to a single variable, from a simple addition to a complex equation.
It's possible to use other variable values in expressions. Notice the use of {} (brackets) to use a variable value instead of the literal string "value"
You can self-reference the assigned variable in an expression using a {&}.
Or use a reduced assignment operation.
Valid Operators
or | Logical OR | Check if a or b is on |
and | Logical AND | Check if a and b are on |
== | Equal | Check if a equals b (case insensitive) |
=== | Strict Equal | Check if a equals b (case sensitive) |
!= | NOT Equal | Check if a not equals b (case insensitive) |
!== | Strict NOT Equal | Check if a not equals b (case sensitive) |
< | Less | Check if a less than b |
<= | Less Equal | Check if a less or equal b |
> | Greater | Check if a greater than b |
>= | Greater Equal | Check if a greater or equal b |
+ | Addition | Sum a plus b |
- | Subtraction | Subtract b from a |
* | Multiplication | Multiply a for b |
/ | Division | Divide a by b |
% | Remainder | Find the remainder of a divided by b |
^ | Power | Power a by b |
On Less, Less Equal, Greater, Greater Equal, Addition, Subtraction, Multiplication, Division, Remainder,and Power operations, it's required that the operands are numeric values. If a non-numeric value is passed, it is converted as follows:
on to 1
off to 0
A Text values is converted to numeric if possible, and to 0, otherwise.
Constructor
The operator constructor (:=) is used to assign a value to a variable only if that variable does not exist. This is useful for setup a script on its first play.
Complement the assignment (=) operator with the new (:) operator:
This is the same as $ x = 1 + 1
, but is executed only if there isn't already a variable called x.
Text Concatenation
The use of brackets allows the formation of texts by concatenation.
Nested Variables Replacement
The use of brackets can also be done nesting a variable inside other variable brackets.
It is possible to use more elaborated replacement pattern if necessary
Constants
Constants work just like variables, they are assigned and handled the same way, but once created, they can't have their value changed.
Constants are declared on all uppercase.
Deleting Variables
You should always remove variables that aren’t required to be permanently stored, as the more variables there are, the more time it takes to execute some tasks.
To delete a variable, call the built-in function Delete and pass the variable's name.
Temporary variables are automatically deleted when the script ends, but you can delete them manually if needed.
Localizing Variables' Text
Although being stored as an Unreal Engin's Text type, Quillscript's Text variables are marked as cultural invariants by default. If the value of a variable must be localized, set its value inside `` (backticks)
Using Variables in Code
Quillscript variables are stored as an Unreal Engine Map of Name to Text. This map is declared in Quillscript Subsystem and is accessible in Blueprints and C++. Check Quillscript Static Library for detailed usage.
Variable Modifier
Check Register Variable Modifier and Unregister Variable Modifier
Under construction
Hard Coding Default Variables
Under construction
Last updated