You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Updating the Beginners Guide
New images all around. Also made lot's of changes to the layout and phrasing.
Added a short section about themes as well.
* Update saving tutorial
* Update Create Custom Events tut
Changed it so the automated way is the only one described now.
Also deleted unused images.
* Add a updating guide for 1.3
* Updating the updating tutorial
* making some edits to the documentation
Co-authored-by: Emilio Coppola <[email protected]>
Copy file name to clipboardExpand all lines: addons/dialogic/Documentation/Content/Events/Custom Events/CreateCustomEvents.md
+39-49
Original file line number
Diff line number
Diff line change
@@ -27,81 +27,76 @@ All of the files that are used for creating a custom Event Block and Handling Sc
27
27
# Making your first custom event in 6 steps
28
28
Let's now create a simple event that will print some text to the Output panel in Godot.
29
29
30
-
### You can avoid the manual copy-pasting part. Go to Dialogic's settings and use the Custom events section [new] button to create and rename an event for you. Make sure to read the guide so you know what is happening in the process.
30
+
## Create the event
31
+
Go to the `settings page` and in the `custom events section` hit the `New` button.
32
+
Fill in a name for your event, a folder name and an id. For the id's I recommend using your name or a string unique to you followed by a number.
33
+
**The id has to be different for every event!!!**
34
+
This is why I recommend the unique string, because it will enable you to share the event with others without breaking their games.
35
+

31
36
32
-
## 1. Create the folder
33
-
First you should create a new folder in `res://dialogic/custom-events` and give it a name that is descriptive and unique.
37
+
When you are ready, hit `Create`. You will see the folder appear in the `FileSystem` under `res://dialogic/custom-events/`.
34
38
35
-
For this print event let's call it `print-event`.
39
+
If you go to the `timeline editor` now, you should already be able to see your event in the event list.
36
40
41
+
### What happened
42
+
This little menu already created a number of things for you:
43
+
- The `EventBlock` (EventBlock.tscn)
44
+
- An example `EventPart` (EventPart_Example.gd/.tscn)
45
+
- The `event handling script` (event_+EVENTID+.gd)
46
+
- A `stylebox` for your event (Stylebox.tres)
37
47
38
-
## 2. The folders content
39
-
Now you should go to `res://addons/dialogic/Example Assets/CustomEvents` and copy all the files from there and paste them into your new folder (In this case: `res://dialogic/custom-events/print-event`)
40
48
41
49
42
-
## 3. The EventBlock (EventBlock.tscn)
43
-
This is a scene that inherits `res://addongs/dialogic/Editor/Events/Templates/EventTemplate.tscn`.
44
-
When you open the scene you can see that all except the root node are grayed out.
50
+
## What next
51
+
The automatic process already setup a lot. But it didn't know the purpose of our event.
52
+
So we will have to add that.
45
53
46
-
**IMPORTANT!!! This file needs to be named `EventBlock.tscn`!!! DO NOT RENAME**
54
+
### | Adding the data
55
+
First we want to open the `EventBlock.tscn` scene. (Do not rename this scene!)
47
56
48
-
### Setting the EventBlock values
49
-
Now select the the root node of that scene. In the inspector you will see a couple of variables to set.
57
+
Select its root node and look at it's exported variables in the inspector.
50
58
51
-
#### EventName and icon
52
-
For now let's set the `Event Name`. I will set mine to `Print Event`.
59
+
We will need to add all the data, that our event can have to the `event_data`.
60
+
You can see, that it alread contains your event id. This needs to be there, do not delete it!
53
61
54
-
#### The Event Data
55
-
Next you also need to think about the data that your event should save/handle.
62
+
I want to be able to set a text that will be printed, when my event is activated, so I'll add an information slot for that:
63
+

56
64
57
-
As said before it has to contain an `event_id`. These ids mostly consist of your "name" and a number. My event_id will be `rabloe_000`.
58
-
*We decided to move away from the actual names so that renaming wouldn't cause lots of rework.*
59
-
*Make sure your "name" is as unique as possible, so you can share custom events with others without trouble.*
65
+
### | Icon and Stylebox
66
+
You can also change your events icon in the inspector. Just drag an image into the `Event Icon`.
60
67
61
-
For the rest of the data I just want to store a string to print. Create the default data as a dictionary in the `event_data` in the inspector.
68
+
Below that, you can open the Stylebox and change its background color, to give your event a unique look.
62
69
63
-
#### Style and Icon
64
-
Now there is also already a stylebox. You can edit it (mainly the background color) to give it a unique style.
65
-
You can also select an icon for your event. The default Dialogic icon size and format is: 22x22 `svg`. You can find the icons used for the built-in events here: `res://addons/dialogic/Images/Event Icons/Main Icons`
66
70
67
71
68
-
69
-
## 4. The Event Blocks Content (EventParts)
72
+
### | The Event Blocks Content (EventParts)
70
73
Right now your event block will be empty so let's change that (if you want to).
71
74
72
75
The content of an EventBlock is separated as `EventParts`. This allows for some reuse.
73
76
There are two places EventParts can be in an EventBlock: The Header (always visible) and the Body (can be hidden).
74
-
*EventParts can also contain other EventParts, but it wont be necessary for most custom events.*
75
77
76
-
*An EventBlock does not have to have a body nor a header EventPart.*
78
+
*An EventBlock does not have to have a body nor a header EventPart. For example the End Branch event has none.*
77
79
78
80
There is already a simple example `EventPart` (Script and Scene) included. You can change it as much as you want.
79
81
80
-
### Loading the data
81
-
In `load_data()` you will need to set the values of your control nodes.
82
+
#### | Loading the data
83
+
In `load_data()` you will need to set the values of your control nodes. This function is called when the event is added to the timeline editor.
82
84
83
-
### Saving changes to the data
85
+
#### | Saving changes to the data
84
86
When the values get changed (listen to it via signals) set the according value in the `event_data` dictionary and call `data_changed()`.
85
87
86
88
This is pretty much all you need to know.
87
89
*If you want to find more examples you can go to `res://addons/dialogic/Editor/Events/Parts/` and look at the EventParts that shape Dialogic's default blocks.*
88
90
89
-
### Using the EventPart
91
+
### | Using the EventPart
90
92
Once you finished everything in your EventPart(s) you need to go into the `EventBlock` scene and set the `header`/`body` variable in the inspector to the new scene(s).
91
93
92
-
Here is how the EventBlock's settings look for me now:
##5. The event handler script (event_yourname_000.gd)
96
+
### | The event handler script (event_yourname_000.gd)
98
97
Once you have your `EventBlock` finished, you need to add the event handling logic.
99
98
100
-
### The correct name
101
-
Dialogic will search your handler script following the format `event_` + your event id.
102
-
So in our case, since the `event_id` is `rabloe_000` the handler scripts needs to be called **exactly**`event_rabloe_000.gd`
103
-
104
-
### The handle_event() function
99
+
#### | The handle_event() function
105
100
If you open the script you will see, that there is only one function by default, the `handle_event()` function.
106
101
107
102
It comes with two usefull pieces of information: the `event_data` and a reference to the `dialog_node`.
@@ -112,21 +107,16 @@ there. But of course you can do a lot more.
112
107
113
108
114
109
Some more stuff is already explained in the script:
115
-
#### Continue
110
+
#####Continue
116
111
Use `dialog_node.load_next_event()` to continue with the next event.
117
112
118
-
#### Waiting
113
+
#####Waiting
119
114
If you don't want the player to interrupt your event, set `dialog_node.waiting` to `true` while your event is handled.
120
115
Don't forget to set it back to `false`.
121
116
122
117
123
118
124
-
## 6. Using your event
125
-
You are as good as done. Just enable custom events in dialogics settings menu.
126
-
Then go into a timeline. Scroll down to the custom events section. There it should be, otherwise you should hit the refresh button.
127
-
128
-
*Go ahead and try it out!*
129
-
130
-
119
+
## And done!
120
+
Great, you've created your first custom event for dialogic.
131
121
132
122
*Make sure to check Emilio's Discord server just in case someone has already created the custom event that you need. They are super easy to [import](./ImportCustomEvents.md)!*
0 commit comments