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: llms-full.txt
+140-1Lines changed: 140 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1878,13 +1878,17 @@ You can interact with the editor using `editor` package that defines this API:
1878
1878
- for atlas animations: `images` (same as `images` in atlas)
1879
1879
- for tilemaps: `layers` (list of editor nodes for layers in the tilemap)
1880
1880
- for tilemap layers: `tiles` (an unbounded 2d grid of tiles), see `tilemap.tiles.*` for more info
1881
+
- for particlefx: `emitters` (list of emitter editor nodes) and `modifiers` (list of modifier editor nodes)
1882
+
- for particlefx emitters: `modifiers` (list of modifier editor nodes)
1883
+
- for collision objects: `shapes` (list of collision shape editor nodes)
1884
+
- for GUI files: `layers` (list of layer editor nodes)
1881
1885
- some properties that are shown in the Properties view when you have selected something in the Outline view. These types of outline properties supported:
1882
1886
- `strings`
1883
1887
- `booleans`
1884
1888
- `numbers`
1885
1889
- `vec2`/`vec3`/`vec4`
1886
1890
- `resources`
1887
-
1891
+
- `curves`
1888
1892
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.
1889
1893
- `editor.can_get(node_id, property)` — check if you can get this property so `editor.get()` won't throw an error.
1890
1894
- `editor.can_set(node_id, property)` — check if `editor.tx.set()` transaction step with this property won't throw an error.
@@ -2091,6 +2095,141 @@ editor.transact({
2091
2095
})
2092
2096
```
2093
2097
2098
+
#### Editing particlefx
2099
+
2100
+
You can edit particlefx using `modifiers` and `emitters` properties. For example, adding a circle emitter with acceleration modifier is done like this:
2101
+
```lua
2102
+
editor.transact({
2103
+
editor.tx.add("/fire.particlefx", "emitters", {
2104
+
type = "emitter-type-circle",
2105
+
modifiers = {
2106
+
{type = "modifier-type-acceleration"}
2107
+
}
2108
+
})
2109
+
})
2110
+
```
2111
+
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:
2112
+
- `x` - the x coordinate of the point, should start at 0 and end at 1
2113
+
- `y` - the value of the point
2114
+
- `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))`.
2115
+
Curve spreads additionally have a `spread` number property.
2116
+
2117
+
For example, setting a particle lifetime alpha curve for an already existing emitter might look like this:
2118
+
```lua
2119
+
local emitter = editor.get("/fire.particlefx", "emitters")[1]
{x = 0, y = 0, tx = 0.1, ty = 1}, -- start at 0, go up quickly
2123
+
{x = 0.2, y = 1, tx = 1, ty = 0}, -- reach 1 at 20% of a lifetime
2124
+
{x = 1, y = 0, tx = 1, ty = 0} -- slowly go down to 0
2125
+
}})
2126
+
})
2127
+
```
2128
+
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.
2129
+
2130
+
#### Editing collision objects
2131
+
2132
+
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)
2231
+
```
2232
+
2094
2233
### Use shell commands
2095
2234
2096
2235
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: manuals/editor-scripts.md
+140-1Lines changed: 140 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -77,13 +77,17 @@ You can interact with the editor using `editor` package that defines this API:
77
77
- for atlas animations: `images` (same as `images` in atlas)
78
78
- for tilemaps: `layers` (list of editor nodes for layers in the tilemap)
79
79
- for tilemap layers: `tiles` (an unbounded 2d grid of tiles), see `tilemap.tiles.*` for more info
80
+
- for particlefx: `emitters` (list of emitter editor nodes) and `modifiers` (list of modifier editor nodes)
81
+
- for particlefx emitters: `modifiers` (list of modifier editor nodes)
82
+
- for collision objects: `shapes` (list of collision shape editor nodes)
83
+
- for GUI files: `layers` (list of layer editor nodes)
80
84
- some properties that are shown in the Properties view when you have selected something in the Outline view. These types of outline properties supported:
81
85
-`strings`
82
86
-`booleans`
83
87
-`numbers`
84
88
-`vec2`/`vec3`/`vec4`
85
89
-`resources`
86
-
90
+
-`curves`
87
91
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.
88
92
-`editor.can_get(node_id, property)` — check if you can get this property so `editor.get()` won't throw an error.
89
93
-`editor.can_set(node_id, property)` — check if `editor.tx.set()` transaction step with this property won't throw an error.
@@ -290,6 +294,141 @@ editor.transact({
290
294
})
291
295
```
292
296
297
+
#### Editing particlefx
298
+
299
+
You can edit particlefx using `modifiers` and `emitters` properties. For example, adding a circle emitter with acceleration modifier is done like this:
300
+
```lua
301
+
editor.transact({
302
+
editor.tx.add("/fire.particlefx", "emitters", {
303
+
type="emitter-type-circle",
304
+
modifiers= {
305
+
{type="modifier-type-acceleration"}
306
+
}
307
+
})
308
+
})
309
+
```
310
+
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:
311
+
-`x` - the x coordinate of the point, should start at 0 and end at 1
312
+
-`y` - the value of the point
313
+
-`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))`.
314
+
Curve spreads additionally have a `spread` number property.
315
+
316
+
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
322
+
{x=0.2, y=1, tx=1, ty=0}, -- reach 1 at 20% of a lifetime
323
+
{x=1, y=0, tx=1, ty=0} -- slowly go down to 0
324
+
}})
325
+
})
326
+
```
327
+
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.
328
+
329
+
#### Editing collision objects
330
+
331
+
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)
430
+
```
431
+
293
432
### Use shell commands
294
433
295
434
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:
0 commit comments