World - Dialogue Module
anvil.api.world.dialogue
Dialogue
Bases: JsonFile[_DialogueFile]
NPC dialogue scenes: text, an NPC name, buttons and the commands they run. A scene
opens in game with /dialogue open <npc> <player> <scene tag>.
dialogue = Dialogue("intro")
scene = dialogue.add_scene("intro")
scene.properties("Ducky", "Hello new friend")
scene.button("Bye", ["say Goodbye"])
dialogue.queue()
Documentation reference
identifier
property
The file's identifier.
name
property
The identifier's name, without its namespace.
__export__()
Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.
__init__(name)
Initializes a dialogue file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The file name. |
required |
__schema__()
classmethod
The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with
the file's type as title and where it is written under x-anvil-file.
Raises:
| Type | Description |
|---|---|
TypeError
|
When the class is an abstract file base, with no document type. |
add_scene(scene)
Adds a scene. Its tag is <namespace>:<scene>.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene
|
str
|
The scene name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_DialogueScene |
_DialogueScene
|
The scene, to set its text, buttons and commands. |
queue()
Queues the dialogue file for export.