Narrat Docs
Search…
Set Function

Set Function

The set function allows you to create variables that will be kept (and saved), which can later be used in conditions.
It takes two parameters:
  • path: The path where you want to save your value. It can be a deep path and will automatically generate nested objects. For example: DATA.level_1.ending
  • value: The value you want to assign to the variable. For example: "good_ending"

Example

In this example, we ask the player a question, store the answer in a variable, and then use that variable in a condition to play a line of dialogue only for players who like surprises
1
set_example:
2
choice:
3
talk cat idle "Do you like surprises?"
4
"Yes":
5
set DATA.like_surprises true
6
"No!":
7
set DATA.like_surprises false
8
$if this.DATA.like_surprises:
9
talk cat idle "Since you like surprises, here's a surprise message"
10
Copied!
Result of the above code
Copy link