Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 769cd94

Browse files
authored
Update creating-extensions.md (#70)
1 parent 24565db commit 769cd94

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

‎documentation/creating-extensions.md‎

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,27 @@ An extension is a folder that contains all the information about these things so
1919
- layout presets
2020
- Dialogic nodes.
2121

22-
## 📜 Content
22+
# 📜 Table of Contents
2323
[toc]
2424

25-
## 1. Getting started
25+
# 1. Getting started
2626

2727
The best way to create an extension is to use the extension creator in the dialogic settings (General).
2828

2929
<img src="/media/extension_creator.png" width="600"/>
3030

31-
By clicking the `Create New Extension` button, you can set up an extension folder and a custom event script. Enter a name for the new module and select what you would like to add. Then click `Create`.
31+
By clicking the `Create New Extension` button, you can set up an extension folder and a custom event script. Enter a name for the new module and select what you would like to add. Then click `Create`. This should create a folder inside your extensions folder with two scripts: `index.gd` and `event_(module name here).gd`.
3232

3333
```admonish warning
3434
Existing files will be overwritten!
3535
```
3636

3737
---
3838

39-
## 2. The essential part: `index.gd`
39+
# 2. The essential part: `index.gd`
4040

4141
The central piece of any extension is the `index.gd` script. It is the only thing your extension is required to have. It has to extend `DialogicIndexer` and can overwrite that class's methods to let Dialogic know what things to add.
42+
4243
For example, this code registers a custom event:
4344

4445
```gdscript
@@ -64,16 +65,16 @@ The Extension Creator allows you to get a basic event script. It has already set
6465

6566
These are the things you need to do to make your event fully functional:
6667

67-
#### 1. Event settings:
68+
### 3.1 Event settings/parameters/properties:
6869

69-
All options for your event should be stored in variables. Define these at the top.
70+
All options for your event (i.e. parameters you can "pass" to your event) should be stored in variables. Define these at the top.
7071

7172
```gdscript
7273
var print_text: String = ""
7374
var in_game: bool = false
7475
```
7576

76-
#### 3.1 Execution code:
77+
### 3.2 Execution code:
7778

7879
Add whatever should happen when your event is reached in the `_execute()` method:
7980

@@ -89,7 +90,7 @@ func _execute() -> void:
8990

9091
*The `finish()` method lets Dialogic know to continue with the next event.*
9192

92-
#### 3.2 General settings:
93+
### 3.3 General settings:
9394

9495
In the `_init()` method, you can set some base settings of your event:
9596

@@ -100,7 +101,7 @@ func _init() -> void:
100101
event_category = "Godot"
101102
```
102103

103-
#### 3.3 Saving & Loading
104+
### 3.4 Saving & Loading (i.e. parsing, representation in timeline's text editor)
104105

105106
We will cover working with shortcodes now. They are pretty much the text view of an event inside the timeline.
106107
The following is the shortcode for the Background event.
@@ -124,7 +125,7 @@ func get_shortcode_parameters() -> Dictionary:
124125

125126
*The above event might be saved as `[print text="Some text to print" in_game="true"]`*
126127

127-
### 3.34 My Variables are not changing
128+
#### 3.4.1 Troubleshooting
128129

129130
If your variables are not changing despite setting values in your custom event in the timeline editor, here is a little checklist:
130131

@@ -150,16 +151,17 @@ If your variables are not changing despite setting values in your custom event i
150151

151152
After all of these values match, the visual and text modes will both change the variables in your event, and you can access them in the `_execute`.
152153

154+
#### 3.4.2 Custom Saving & Loading Syntax
153155

154-
## 4.1 Custom Saving & Loading Syntax
155-
156-
You can implement custom saving syntax by overriding the function `to_text() -> String` and `from_text(timeline_event: String)`.
156+
You can also implement custom saving syntax by overriding the function `to_text() -> String` and `from_text(timeline_event: String)`.
157157
The `is_valid_event(event_name: String) -> bool` needs to be override too, if you want to quickly check if the event name is correct.
158158

159159
When is custom saving and loading useful? If your shortcode has a special text syntax or is converting between values, map a word to an integer.
160160
This is what the text-, character-, choice-, condition-, and variable events do, so take a look at them if this is something you are interested in.
161+
A good example of this is the Comment event, which you can find under `addons/dialogic/modules/comment`.
162+
161163

162-
#### 5. Editor fields:
164+
### 3.5 Visual Editor fields:
163165

164166
Your event is now fully functional, but in the visual editor, it is still blank. You will need to override the `build_event_editor()` method to define the fields/texts that will appear on the event.
165167

@@ -173,9 +175,13 @@ func build_event_editor() -> void:
173175

174176
If you would like to learn more about events, I strongly suggest looking at the built-in events.
175177

178+
#### 3.5.1 Troubleshooting
179+
180+
If your custom event does not show up in the visual editor, but functions when written in the text editor, considering restarting Godot for changes to take hold.
181+
176182
---
177183

178-
# 5. Custom Subsystems
184+
# 4. Custom Subsystems
179185

180186
## What is a subsystem?
181187

@@ -198,7 +204,7 @@ If you want to save persistent data, store it in the `Dialogic.current_state_inf
198204

199205
---
200206

201-
# 6. Custom animations
207+
# 5. Custom animations
202208

203209
## What is an animation?
204210

@@ -254,7 +260,7 @@ Importantly, the name of your animation file will determine if it is a Join, Lea
254260

255261
---
256262

257-
# 7. Custom dialogic nodes
263+
# 6. Custom dialogic nodes
258264

259265
## What are dialogic nodes?
260266

@@ -265,7 +271,7 @@ They are generally managed by a subsystem and are found because they are automat
265271

266272
---
267273

268-
# 8. Custom Settings Pages
274+
# 7. Custom Settings Pages
269275

270276
An extension might want to add a dialogic settings editor. This is just a UI scene that has a script inheriting `DialogicSettingsPage`.
271277

0 commit comments

Comments
 (0)