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/en/en.json
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -908,6 +908,20 @@
908
908
"description": "This course teaches you to build a farming RPG in Defold, covering player control, crop systems, day progression, sprite atlases, data management, and UI design. Basic Defold and Lua knowledge is needed. Gain skills for advanced and complex projects.",
"name": "Make a Fully-Fledged 2D Action RPG in Defold",
915
+
"description": "This course covers building a complete 2D action RPG in Defold, teaching core mechanics like player control, enemy AI, dynamic cameras, health bars, scene management, and spawning systems.",
"description": "This course covers building a complete block breaker game in Defold, teaching physics-based gameplay, paddle and ball mechanics, and procedural block generation using scripting.",
Copy file name to clipboardExpand all lines: docs/en/manuals/editor-scripts.md
+216-3Lines changed: 216 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,13 +56,17 @@ You can interact with the editor using `editor` package that defines this API:
56
56
- for atlas animations: `images` (same as `images` in atlas)
57
57
- for tilemaps: `layers` (list of editor nodes for layers in the tilemap)
58
58
- for tilemap layers: `tiles` (an unbounded 2d grid of tiles), see `tilemap.tiles.*` for more info
59
+
- for particlefx: `emitters` (list of emitter editor nodes) and `modifiers` (list of modifier editor nodes)
60
+
- for particlefx emitters: `modifiers` (list of modifier editor nodes)
61
+
- for collision objects: `shapes` (list of collision shape editor nodes)
62
+
- for GUI files: `layers` (list of layer editor nodes)
59
63
- some properties that are shown in the Properties view when you have selected something in the Outline view. These types of outline properties supported:
60
64
-`strings`
61
65
-`booleans`
62
66
-`numbers`
63
67
-`vec2`/`vec3`/`vec4`
64
68
-`resources`
65
-
69
+
-`curves`
66
70
Please note that some of these properties might be read-only, and some might be unavailable in different contexts, so you should use `editor.can_get` before reading them and `editor.can_set` before making editor set them. Hover over property name in Properties view to see a tooltip with information about how this property is named in editor scripts. You can set resource properties to `nil` by supplying `""` value.
67
71
-`editor.can_get(node_id, property)` — check if you can get this property so `editor.get()` won't throw an error.
68
72
-`editor.can_set(node_id, property)` — check if `editor.tx.set()` transaction step with this property won't throw an error.
@@ -123,16 +127,17 @@ return M
123
127
Editor expects `get_commands()` to return an array of tables, each describing a separate command. Command description consists of:
124
128
125
129
-`label` (required) — text on a menu item that will be displayed to the user
126
-
-`locations` (required) — an array of either `"Edit"`, `"View"`, `"Project"`, `"Debug"`, `"Assets"`, `"Bundle"` or `"Outline"`, describes a place where this command should be available. `"Edit"`, `"View"`, `"Project"` and `"Debug"` mean menu bar at the top, `"Assets"` means context menu in Assets pane, `"Outline"` means context menu in Outline pane, and `"Bundle"` means **Project → Bundle** submenu.
130
+
-`locations` (required) — an array of either `"Edit"`, `"View"`, `"Project"`, `"Debug"`, `"Assets"`, `"Bundle"`, `"Scene"` or `"Outline"`, describes a place where this command should be available. `"Edit"`, `"View"`, `"Project"` and `"Debug"` mean menu bar at the top, `"Assets"` means context menu in Assets pane, `"Outline"` means context menu in Outline pane, and `"Bundle"` means **Project → Bundle** submenu.
127
131
-`query` — a way for command to ask editor for relevant information and define what data it operates on. For every key in `query` table there will be corresponding key in `opts` table that `active` and `run` callbacks receive as argument. Supported keys:
128
132
-`selection` means this command is valid when there is something selected, and it operates on this selection.
129
133
-`type` is a type of selected nodes command is interested in, currently these types are allowed:
130
134
-`"resource"` — in Assets and Outline, resource is selected item that has a corresponding file. In menu bar (Edit or View), resource is a currently open file;
131
135
-`"outline"` — something that can be shown in the Outline. In Outline it's a selected item, in menu bar it's a currently open file;
136
+
-`"scene"` — something that can be rendered to the Scene.
132
137
-`cardinality` defines how many selected items there should be. If `"one"`, selection passed to command callback will be a single node id. If `"many"`, selection passed to command callback will be an array of one or more node ids.
133
138
-`argument` — command argument. Currently, only commands in `"Bundle"` location receive an argument, which is `true` when the bundle command is selected explicitly and `false` on rebundle.
134
139
-`id` - command identifier string, used e.g. for persisting the last used bundle command in `prefs`
135
-
-`active` - a callback that is executed to check that command is active, expected to return boolean. If `locations` include `"Assets"` or `"Outline"`, `active` will be called when showing context menu. If locations include `"Edit"` or `"View"`, active will be called on every user interaction, such as typing on keyboard or clicking with mouse, so be sure that `active` is relatively fast.
140
+
-`active` - a callback that is executed to check that command is active, expected to return boolean. If `locations` include `"Assets"`, `"Scene"` or `"Outline"`, `active` will be called when showing context menu. If locations include `"Edit"` or `"View"`, active will be called on every user interaction, such as typing on keyboard or clicking with mouse, so be sure that `active` is relatively fast.
136
141
-`run` - a callback that is executed when user selects the menu item.
137
142
138
143
### Use commands to change the in-memory editor state
@@ -269,6 +274,214 @@ editor.transact({
269
274
})
270
275
```
271
276
277
+
#### Editing particlefx
278
+
279
+
You can edit particlefx using `modifiers` and `emitters` properties. For example, adding a circle emitter with acceleration modifier is done like this:
280
+
```lua
281
+
editor.transact({
282
+
editor.tx.add("/fire.particlefx", "emitters", {
283
+
type="emitter-type-circle",
284
+
modifiers= {
285
+
{type="modifier-type-acceleration"}
286
+
}
287
+
})
288
+
})
289
+
```
290
+
Many particlefx properties are curves or curve spreads (i.e. curve + some randomizer value). Curves are represented as a table with a non-empty list of `points`, where each point is a table with the following properties:
291
+
-`x` - the x coordinate of the point, should start at 0 and end at 1
292
+
-`y` - the value of the point
293
+
-`tx` (0 to 1) and `ty` (-1 to 1) - tangents of the point. E.g., for an 80-degree angle, `tx` should be `math.cos(math.rad(80))` and `ty` should be `math.sin(math.rad(80))`.
294
+
Curve spreads additionally have a `spread` number property.
295
+
296
+
For example, setting a particle lifetime alpha curve for an already existing emitter might look like this:
{x=0, y=0, tx=0.1, ty=1}, -- start at 0, go up quickly
302
+
{x=0.2, y=1, tx=1, ty=0}, -- reach 1 at 20% of a lifetime
303
+
{x=1, y=0, tx=1, ty=0} -- slowly go down to 0
304
+
}})
305
+
})
306
+
```
307
+
Of course, it's also possible to use the `particle_key_alpha` key in a table when creating an emitter. Additionally, you can use a single number instead to represent a "static" curve.
308
+
309
+
#### Editing collision objects
310
+
311
+
In addition to default outline properties, collision objects define `shapes` node list property. Adding new collision shapes is done like this:
print(editor.can_reset(node_in_template, "text")) -- true (overrides a value in the template)
410
+
```
411
+
412
+
#### Editing game objects
413
+
414
+
It's possible to edit components of a game object file using editor scripts. The components come in 2 flavors: referenced and embedded. Referenced components use type `component-reference` and act as references to other resources, only allowing overrides of go properties defined in scripts. Embedded components use types like `sprite`, `label`, etc., and allow editing of all properties defined in the component type, as well as adding sub-components like shapes of collision objects. For example, you can use the following code to set up a game object:
415
+
```lua
416
+
editor.transact({
417
+
editor.tx.add("/npc.go", "components", {
418
+
type="sprite",
419
+
id="view"
420
+
}),
421
+
editor.tx.add("/npc.go", "components", {
422
+
type="collisionobject",
423
+
id="collision",
424
+
shapes= {
425
+
{
426
+
type="shape-type-box",
427
+
dimensions= {32, 32, 32}
428
+
}
429
+
}
430
+
}),
431
+
editor.tx.add("/npc.go", "components", {
432
+
type="component-reference",
433
+
path="/npc.script"
434
+
id="controller",
435
+
__hp=100-- set a go property defined in the script
436
+
})
437
+
})
438
+
```
439
+
440
+
#### Editing collections
441
+
It's possible to edit collections using editor scripts. You can add game objects (embedded or referenced) and collections (referenced). For example:
__hp=100-- set a go property defined in the script
477
+
}
478
+
}
479
+
})
480
+
})
481
+
```
482
+
483
+
Like in the editor, referenced collections can only be added to the root of the edited collection, and game objects can only be added to embedded or referenced game objects, but not to referenced collections or game objects within these referenced collections.
484
+
272
485
### Use shell commands
273
486
274
487
Inside the `run` handler, you can write to files (using `io` module) and execute shell commands (using `editor.execute()` command). When executing shell commands, it's possible to capture the output of a shell command as a string and then use it in code. For example, if you want to make a command for formatting JSON that shells out to globally installed [`jq`](https://jqlang.github.io/jq/), you can write the following command:
Copy file name to clipboardExpand all lines: docs/en/manuals/factory.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,7 +263,6 @@ The project setting *max_instances* in *Collection related settings* limits the
263
263
264
264
If you set *max_instances* to 1024 and have 24 manually placed game objects in your main collection, you can spawn an additional 1000 game objects. As soon as you delete a game object, you are free to spawn another instance.
265
265
266
-
267
266
## Pooling of game objects
268
267
269
268
It may seem like a good idea to save spawned game objects in a pool and reuse them. However, the engine is already doing object pooling under the hood so additional overhead will only slow things down. It is both faster and cleaner to delete game objects and spawn new ones.
The resource tree in a Defold game is static so any dependencies that you need for your GUI nodes need to be added to the component. The *Outline* groups all dependencies by type under "folders":
0 commit comments