When you want to change variables from script, you do it with a
set
line, for example:
[set SomeNumber 9]
Optionally you can use an "
=
" between the variable name and the value if you want, but you don't have to.
All variables are considered to be dialogue scoped variables,
unless they are prefixed with global.
, in which case they are set as
global variables.
# This sets a global variable which persists across all dialogues
[set global.SomeBool true]
Here's how you set variables using each of the supported types from simple literals:
[set SomeInt 5]
[set SomeFloat 53.835]
Note: do not include any suffix like 'f'
[set SomeBool true]
Supported arguments are
true
,True
,false
andFalse
This is for text (FText) you expect to display to the player.
[set SomeText "Hello world"]
You can include double quotes inside text by using the escape (\
) character:
[set SomeText "This includes some \"Quoted\" text"]
Note: Literal text is automatically tagged for localisation just like text in speaker lines and choices.
Names (FNames) are not localised unlike text, so are good for signalling more descriptive values to / from code.
[set SomeName `HelloWorld`]
[set SomeGender feminine]
The 3 gender options are
masculine
,feminine
andneuter
Rather than a literal value, you can set a variable based on an expression, which is a potentially compound statement, which can reference other variables and perform operations.
See the Expressions section for a complete discussion, but for example you could do things like this:
[set SomeInt = {SomeInt} + 1]
[set SomeBoolean = {AIsTrue} or {BIsTrue}]
[set IsLargeEnough = {SomeInt} > 10]
Note that I've used the '
=
' symbol here; I don't have to, it's optional, but I find it easier to read when there are expressions on the right instead of literals.