PopochiuIDialog
Inherits: Node
Description
Provides access to the project's PopochiuDialogs via the singleton D (for example:
D.AskAboutLoom.start()).
Use this interface to start and manage branching dialogs and to listen for option selection events.
Capabilities include:
-
Start a branching dialog.
-
Detect when a dialog finishes or when an option is selected.
-
Create and show an inline list of options at runtime.
Use examples:
func on_click() -> void:
# Create a dialog with 3 options
var opt: PopochiuDialogOption = await D.show_inline_dialog([
"Ask Popsy something", "Give Popsy a hug", "Do nothing"
])
# The options IDs will go from 0 to the size - 1 of the array passed to D.show_inline_dialog
match opt.id:
"0": # "Ask Popsy something" was selected
D.ChatWithPopsy.start() # Start the ChatWithPopsy dialog
"1": # "Give Popsy a hug" was selected
await C.walk_to_clicked()
await C.player.play_hug()
"2": # "Do nothing" was selected
await C.player.say("Maybe later...")
Properties
| Type | Name | Default |
|---|---|---|
| Variant | active | false |
| PopochiuDialog | current_dialog | null |
| PopochiuDialog | prev_dialog | null |
| PopochiuDialogOption | selected_option | null |
| Variant | trees | {} |
Methods
| Return Type | Method |
|---|---|
| String | create_gibberish(input_string: String) |
| void | finish_dialog() |
| PopochiuDialog | get_instance(script_name: String) |
| void | say_selected() |
| void | set_current_dialog(value: PopochiuDialog) |
| PopochiuDialogOption | show_inline_dialog(options: Array) |
Signals
- dialog_finished(dlg: PopochiuDialog)
- dialog_options_requested(options: Array[PopochiuDialogOption])
- dialog_started(dlg: PopochiuDialog)
- inline_dialog_requested(options: Array)
- option_selected(opt: PopochiuDialogOption)
Signal Descriptions
dialog_finished
signal dialog_finished(dlg: PopochiuDialog)
Emitted when dlg finishes.
dialog_options_requested
signal dialog_options_requested(options: Array[PopochiuDialogOption])
Emitted when the list of available options for the current dialog is requested.
dialog_started
signal dialog_started(dlg: PopochiuDialog)
Emitted when dlg starts playing.
inline_dialog_requested
signal inline_dialog_requested(options: Array)
Emitted when an inline dialog is created. It carries the list of configured options.
option_selected
signal option_selected(opt: PopochiuDialogOption)
Emitted when an opt is selected in the current dialog.
Property Descriptions
active
var active = false
Whether a dialog is currently active.
current_dialog
var current_dialog : PopochiuDialog = null
- Setter:
set_current_dialog
Currently running dialog instance. Setter handles lifecycle (waits for the current dialog to finish) and state saving.
Can be null if no dialog is active.
prev_dialog
var prev_dialog : PopochiuDialog = null
The previous branch that has been ran in the dialog tree; useful to return after exhausting options.
selected_option
var selected_option : PopochiuDialogOption = null
Currently selected option in the active dialog.
trees
var trees = {}
Stores the runtime state of every PopochiuDialog in the project.
Keys are each dialog's script_name.
Method Descriptions
create_gibberish
func create_gibberish(input_string: String) -> String
Converts input_string to gibberish while preserving bbcode tags. Returns the transformed String.
Main use case:
- mask possible spoilers in pre-release or demo builds
Other uses:
-
make clear that a character is speaking a language unknown to the player until a translation item is found
-
create humorous effect when the player is confused, drunk or otherwise not fully aware
finish_dialog
func finish_dialog() -> void
Stops the currently running PopochiuDialog by emitting dialog_finished.
get_instance
func get_instance(script_name: String) -> PopochiuDialog
Loads and returns the PopochiuDialog resource identified by script_name as defined in
Instantiates and returns the PopochiuDialog resource referenced by script_name from
project data. Logs an error and returns null if not found.
say_selected
func say_selected() -> void
Makes the Player-controlled Character (PC) speak the text of selected_option.
set_current_dialog
func set_current_dialog(value: PopochiuDialog) -> void
show_inline_dialog
func show_inline_dialog(options: Array) -> PopochiuDialogOption
Displays an inline list of PopochiuDialogOption options and returns the selected one.
While the inline dialog is shown, the dialog system is marked active. Restores previous dialog
option handling once selection completes.