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/events/js-code/javascript-in-extensions/index.md
+9-4Lines changed: 9 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,7 +111,7 @@ for (const player of players) {
111
111
112
112
After getting the events function parameter values, you can pass them to a JavaScript function.
113
113
114
-
#### Call a "static" function of the library
114
+
#### Call a "static" function of the library
115
115
116
116
```javascript
117
117
gdjs._myNewExtension.doSomething(myParameter);
@@ -161,7 +161,7 @@ In case you are writing your first custom behavior, please refer to the [custom
161
161
162
162
### Get an object behavior in Javascript
163
163
164
-
Behaviors parameter values are actually just a string of the behavior name. Each object instance has their own behavior instance so it avoids to pass an array for behaviors when they can be mapped from objects with `object.getBehavior(behaviorName)`.
164
+
Behaviors parameter values are actually just a string of the behavior name. Each object instance has their own behavior instance so it avoids to pass an array for behaviors when they can be mapped from objects with `object.getBehavior(behaviorName)`.
165
165
166
166
For actions and conditions of behaviors, the object parameter **Object** only contains one instance because GDevelop does the iteration on object instances. For other object parameters you still need to iterate on all instances.
167
167
@@ -214,14 +214,19 @@ This is a few instances of extensions that use JavaScript:
214
214
215
215
## Experimental new option: JavaScript files in your project
216
216
217
-
Starting with GDevelop 5.5.222, you can also open the extension properties, and then add a JavaScript source file.
217
+
Starting with GDevelop 5.5.222, you can also open the extension properties, and then add a JavaScript source file:
218
+
219
+

220
+
218
221
This source file will be:
219
222
220
-
- imported as the same time as the files of the game engine or other extensions. It can either be set to be imported before the game engine files or after (but the order between files is not guaranteed).
223
+
-**only imported if the extension is used** in your game (for example, a scene uses an action or condition from the extension).
224
+
- imported as the same time as the files of the game engine or other extensions. It can either be set to be imported before the game engine files or after (but the order between files is not guaranteed). It works both for the preview and when the game is exported.
221
225
- no transpilation or changes are done on the file.
222
226
- the file will be added as a "JavaScript" resource in the resources editor.
223
227
224
228
!!! warning
225
229
230
+
Remember to make sure your extension is used by the game so that the file is included.
226
231
If you export your extension, this file *won't* be included. Consider this option as an experimental option to add custom JavaScript code to a project.
0 commit comments