articy:draft features its own scripting language, called "articy:expresso". In articy:draft, it is most useful when combined with Global Variables, built-in functions, and the Simulation mode, allowing users to test the logic of their narrative.
The ArticyImporter plugin imports your scripts into Unity, providing you with the flexibility to apply them as you see fit. Additionally, the ArticyFlowPlayer will use the scripts found inside the flow when traversing it.
This guide provides an overview on how to take advantage of articy:expresso and how to make use of the scripts within Unity.
In case you are unfamiliar with articy:expresso and how to use it inside of articy:draft, consider the summary below, or head directly to the more exhaustive HelpCenter documentation.
We distinguish between two types of scripts in articy:expresso:
Condition: A boolean expression
Instructions: A set of statements, separated by semicolon, usually used to change the state of variables or invoke functions
articy:draft users can define scripts in three different contexts:
Pins: Conditions are used in InputPins to constrain flow execution on a given path, while instructions are defined on OutpuPins.
Condition and Instructions nodes: Similar to Input- and OutputPins, there are two dedicated node types in articy:draft to define the two respective types of scripts.
Script template properties: Users can define template properties of type "script" and assign a script type ("condition", "instructions", or "no error validation"), which only affects the script validation internal to articy:draft.
Condition scripts
A condition script is an arbitrary boolean expression, i.e. an expression that evaluates to either the value "True" or "False". An empty condition script is evaluated to "True". Here are some example condition scripts:
articy:expresso supports commonly known operators and their semantics, including comparison operators (<, <=, ==, !=, >, >=), logical operators (&& / AND, || / OR) and the logical negation operator (!). Additionally, operands can be calculated values, based off of function calls and arithmetic expressions.
Instructions scripts
Instructions are a set of assignment statements in the form <l-value> <assignment-operator> <r-value>.
articy:expresso supports commonly known assignment operators and their semantics (=, +=, -=, *=, /=, %=). While the l-value has to be a defined, mutable variable, the r-value can be an arbitrary expression of the same type as the l-value (otherwise, type validation will report an error in articy:draft).
Accessing objects, properties and templates
Historically, articy:expresso was designed to be used in conjunction with Global Variables. While this was sufficient for a lot of use cases, it can be more useful to store the data alongside the objects directly. Especially given the flexibility that was added with the template system, we introduced specialized functions to the scripting system to access properties and the template data of objects.
Additionally, there exist several convenience functions and keywords in articy:expresso to facilitate common tasks.
Overview over built-in functions (detailed explanations and samples in the next section):
Note
Note that the Variable type wraps values of supported types for those functions where it is used. For example, isInRange can be used with integer, floating, and string values, as long as the types of the lowerBound and upperBound arguments can be treated the same way as the type of the value argument.
Remember that a Condition script must be a boolean expression. Hence, certain functions or keywords like print(...), setProp(...) or setSeenCounter(...) cannot be used in Condition scripts.
Utility functions reference
getObj(identifier : string, instanceId : int = 0) : ObjectRef
This function is used in conjunction with functions like getProp() and setProp().
You can access an object via its technical name or id.
Evaluates to false if any other non-fallback branch in reference to the given branchingPointRef is currently valid. By default (i.e. without an explicit branchingPointRef argument), the branchingPoint is determined by the ArticyFlowPlayer.