meat_madness_redux/godot/addons/dialogic/Documentation/Content/Reference/001.md

166 lines
5.1 KiB
Markdown
Raw Permalink Normal View History

2022-11-27 13:31:09 -07:00
# Dialog Class
The Dialogic class provides pretty much all the methods you need to interact with Dialogic via code.
You can access them simply by using the class name `Dialogic.method_i_want_to_call()`.
## Starting Dialog
### start()
`start(timeline, default_timeline, dialog_scene_path, use_canvas_instead)`
Starts the dialog for the given timeline and returns a Dialog node.
You must then add it manually to the scene to display the dialog.
Example:
```
var new_dialog = Dialogic.start('Your Timeline Name Here')
add_child(new_dialog)
```
`@param timeline`
The timeline you wish to load. You can provide the timeline name or the filename, at your discretion. Leave this empty to start from a save slot.
We encourage you to specify the timeline name with the folders in front (e.g. 'Part 1/Chapter 1').
`@param default_timeline`
If timeline == '' (so it's loading from the save slot) and no valid data was found, this will be loaded.
`@param dialog_scene_path`
If you made a custom Dialog scene or moved it from its default path, you can specify its new path here.
`@param use_canvas_instead`
True by default. Creates the Dialog inside a canvas layer to make it show up regardless of the camera 2D/3D situation.
**@returns**
A Dialog node to be added into the scene tree (see example above).
### change_timeline()
`change_timeline(timeline)`
Is used to change the current timeline. This way the state of the DialogNode (like characters, the theme and background music) are preserved from the currently active node.
`@param timeline`
Same as the one on `start()`, although it cannot load from saves.
### next_event()
`next_event(discreetly)`
Is used to immediately play the next event.
`@param discreetly`
A boolean (default value: false) that determines whether the Passing Audio will be played.
### timeline_exists()
`timeline_exists(timeline)`
Returns true if a timeline with the given name at the given path exists, otherwise false.
`@param timeline`
The name/path to check.
## Saving and loading
The Dialogic class provides the following methods for dealing with saving and loading. Learn more about how to use them in the Saving and Loading tutorial.
### load()
`load(slot_name)`
`@param slot_name`
Specifies the slot name to be loaded. If empty, it will load the default save.
### save()
`save(slot_name)`
`@param slot_name`
Specifies the slot name to be saved to. If empty, it will save to the default slot.
### get_slot_names()
`get_slot_names()`
**@returns**
An array with all the available slot names.
### erase_slot()
`erase_slot(slot_name)`
`@param slot_name`
Specifies the slot name to be deleted.
### has_current_dialog_node()
`has_current_dialog_node()`
**@returns**
True if there is a Dialog Node active, otherwise false.
### reset_saves()
`reset_saves(slot_name)`
`@param slot_name`
Specifies the slot to be reset. Uses the default slot if left empty.
### get_current_slot()
`get_current_slot()`
**@returns**
The name of the last loaded slot or "/" if import() was used.
### export()
`export()`
Is used to get all necessary info, so you can save it however you want.
**@returns**
A dictionary with all important information about the dialogic game state.
There are three sub-dictionaries with the keys 'definitions', 'state' and 'dialog_state'.
- *'definitions'* contains all the definitions, values as well as glossary entries (only their current value, not the defaults
- *'state'* contains the so called "game_state": custom information that can be accessed with the `Dialogic.get_saved_state_general_key()` and `Dialogic.set_saved_state_general_key()` methods.
- *'dialog_state'* that contains all information needed to load the dialog back in (if any dialog was playing when export() is called. Example information is the current timeline, event index, characters on screen with their portraits, background, music, etc...
### import()
`import(data)`
Is used to load data that was exported back in.
`@param data`
A dictionary that should be the same as the one you get from `export()`.
## Variables
You can change the value definitions through your code!
### set_variable()
`set_variable(name, value)`
Sets the value of the value definition named `@param name` to `@param value`.
### get_variable()
`get_variable(name, default)`
Returns the current (not default) value of the value definition named `@param name` or `@param default` if no value definition like that was named.
### clear_all_variables()
`clear_all_variables()`
Clears all configured variables.
## Game State
The game state is custom information that you can access with the following functions and that will be saved and loaded alongside the other dialogic data.
### get_saved_state_general_key()
`get_saved_state_general_key(key, default)`
**@returns**
The value of the given `@param key` or `@param default` if nothing is found.
### set_saved_state_general_key()
`set_saved_state_general_key(key, value)`
Changes the value of the given `@param key` to the value of `@param value`.
## Other stuff
### get_action_button()
Mostly used for internal purposes.
**@returns**
The input action selected on the dialogic setting page.