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
Copy file name to clipboardExpand all lines: docs/gdevelop5/behaviors/events-based-behaviors/index.md
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,14 +142,11 @@ Properties can also be used to required behaviors as described in a following se
142
142
143
143
### Use actions and conditions to manipulate the properties
144
144
145
-
Once you have created some properties on your behavior, conditions and actions will be automatically added in the events sheet. For each property, there will be a condition to compare its value, and an action for changing it.
146
-
Strings and numbers will also have an expression to get their values.
145
+
Number, string and boolean parameters can be used with the same actions and conditions as global and scene [variables](/gdevelop5/all-features/variables). Properties can also be used directly in expressions by writing their name. For instance, a property called "ScoreToMultiply" can be used the following: `2 * ScoreToMultiply`.
147
146
148
-
!!! note
149
-
150
-
If you rename your properties, the actions/conditions/expressions will be updated automatically.
147
+
Properties won't be usable from outside of the behavior. Properties are said to be "private", they can only be manipulated by the behavior. If you want to let extension users modifying them from the scene events, you can generate an action and a condition from the drop-down menu of the property.
151
148
152
-
These actions/conditions/expressions won't be usable from outside of the behavior. Properties are said to be "private", they can only be manipulated by the behavior. If you want to let extension user modifying them from the scene events, you can generate an action and a condition from the drop-down menu of the property.
Copy file name to clipboardExpand all lines: docs/gdevelop5/events/functions/index.md
+22-9Lines changed: 22 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,9 +25,9 @@ Functions are grouped into [extensions](/gdevelop5/extensions). They are the sam
25
25
26
26
Click on **Create or search for new extensions** at the bottom. Then, select **Create a new extension** to [create a new extension](/gdevelop5/extensions/create).
27
27
28
-
By default, extensions don't have any function. Add one by clicking on **Add a new function**on the left.
28
+
By default, extensions don't have any function. Add one by clicking on the "+" button on the left next to **Functions**.
29
29
30
-

30
+

31
31
32
32
A new function is added, it's time to give it a name. By convention:
33
33
@@ -79,9 +79,11 @@ Conditions and actions from behaviors can also be used in functions events. For
79
79
80
80
#### Use parameter values
81
81
82
-
A number, string and boolean parameter values can be compared with conditions.
82
+
Number, string and boolean parameters can be compared with the same conditions as global and scene [variables](/gdevelop5/all-features/variables).
83
83
84
-

84
+
!!! note
85
+
86
+
Parameter values can't be changed with actions. If you want to give back a value to scene events, you have to create a [custom expression](#return-a-value-from-a-function).
85
87
86
88
Parameters can also be used directly in expressions by writing their name. For instance, a parameter called "ScoreToMultiply" can be used the following: `2 * ScoreToMultiply`.
87
89
@@ -109,19 +111,30 @@ Function that are conditions or expressions must return a value. The returned va
109
111
110
112
### Use variables from function events
111
113
112
-
Variable can be useful within functions for intermediary results or to keep a state in the extension.
113
-
From function events, expressions must be used to access variable values:
114
+
Variables can be useful within functions for intermediary results or to keep a state in the extension. You can declare new [variables](/gdevelop5/all-features/variables) that are accessible only inside the extension by clicking on **Extension global variables** or **Extension scene variables**.
114
115
115
-
-`GlobalVariable(MyVariable)` for global variables
116
-
-`Variable(MyVariable)` for scene variables
117
-
-`MyObject.Variable(MyVariable)` for object variables
116
+
!!! tip
117
+
118
+
If you feel the need to modify object variables, there is a good chance that you should rather make a [custom behavior](/gdevelop5/behaviors/events-based-behaviors/) and use properties.
118
119
119
120
## Use functions in events
120
121
121
122
Extension functions can be found in conditions and actions lists like any other feature of the engine.
122
123
123
124

124
125
126
+
## Write functions dedicated to your project
127
+
128
+
You probably used extensions from the community. These extensions aim to be usable in many projects, but extensions can also be created with only one project in mind.
129
+
130
+
The [platformer template](https://gdevelop.io/game-example/free/platformer) has a `Player` extension with a few functions. For instance, the function `AnimateFallingIntoPortal` uses a few actions to make an animation that is played at the end of the level.
131
+
132
+

133
+
134
+
Visual and sound effects can quickly take a lot of space. Making small functions like this allow to keep the scene events easy to follow.
135
+
136
+

137
+
125
138
## Advanced usages
126
139
127
140
This page gave a basic overview of what functions are. They are one of the more powerful features of GDevelop, as you can extend the events by using them, enabling to create very readable and concise events sheets. By using them, you can reduce the amounts of events that you write for your game, avoid copy-pasting them and even reduce bugs by ensuring that functions are always used for common tasks on your objects.
0 commit comments