> For the complete documentation index, see [llms.txt](https://virtualfactory.gitbook.io/vlft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://virtualfactory.gitbook.io/vlft/kb/instantiation/statechart.md).

# Statechart

The statechart is defined as a json document according to [Xstate formalism](https://stately.ai/docs/machines).

The following types of native xstate action can be used:

* "**xstate.raise**" to send an internal event with attribute "**event**" defining the event (a string with the event name or an object with attributes "type" for the event name and any additional payload)

The following customized types of action can be defined:

* "**ActionShow**" ("**show**") to make appear the asset "**target**" in a given place. Additional attributes are: "**position**" (array), "**rotation**" (array), "**placementRelTo**" (string), "**delay**" (milliseconds as integer).
* "**ActionHide**" ("**hide**") to hide the asset "**target**". Additional attributes are: "**delay**" (milliseconds as integer).
* "**ActionMoveTo**" ("**moveTo**") to move the asset "**target**" to a given place. Additional attributes are: "**position**" (array), "**rotation**" (array), "**placementRelTo**" (string), "**delay**" (milliseconds as integer), "**duration**" (milliseconds as integer).
* "**ActionMoveAdditive**" ("**moveAdditive**") to move the asset "**target**" incrementally from the current place. Additional attributes are: "**position**" (array), "**rotation**" (array), "**delay**" (milliseconds as integer), "**duration**" (milliseconds as integer), "**loop**" (boolean, set to **true** if the movement must be repeated in loop).
* "**ActionSurfaceVelocity**" ("**surfaceVelocity**") to set the surface velocity of asset "**target**". Additional attributes are: "**velocity**" (array), "**delay**" (milliseconds as integer).
* "**ActionGenerateAsset**" ("**genAsset**") to generate a new asset modeled after the asset "**target**". Additional attributes are: "**position**" (array), "**rotation**" (array), "**placementRelTo**" (string), "**delay**" (milliseconds as integer).
* "**ActionSetRepresentation**" ("**setRepresentation**") to set the representation (3D model) of the asset "**target**". Additional attributes are: "**reprref**" (string) to set the URI reference of the 3D model, "**color**" (array) to set the RGB color, "**intensity**" (double ≥ 0) to set the color emissive intensity, "**blink**" (milliseconds as integer) to set the blinking interval, "**delay**" (milliseconds as integer).
* "**ActionSendEvent**" ("**EventGeneration**", "**sendEvent**") to generate an event with" attribute "**event**" defining the event (a string with the event name or an object with attributes "type" for the event name and any additional payload), "**to**" specifying the id of the statechart receiving the event (optional, if missing it is sent to the same statechart that contains the action), "**delay**" (optional delay in milliseconds as integer).

The following actions are available to update the value of variables in the extended state for each statecharts:

* **"updateVariableSet"**, that must be triggered by an event with a payload having "**variable**" for the variable name and "**value**" for the value of the variable to be set.
* **"updateVariableAdd"**, that must be triggered by an event with a payload having "**variable**" for the variable name and "**value**" for the quantity to be added to the variable.
* **"updateVariableSet"**, that must be triggered by an event with a payload having "**variable**" for the variable name and "**value**" for the quantity to be subtracted from the variable.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://virtualfactory.gitbook.io/vlft/kb/instantiation/statechart.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
