brs-js 2.1.3 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -190
- package/dist/dist.js +6 -1
- package/dist/dist.js.map +1 -1
- package/dist/dist.mjs +7389 -0
- package/dist/dist.mjs.map +1 -0
- package/dist/dist.node.js +6 -1
- package/dist/dist.node.js.map +1 -1
- package/dist/dist.web.js +6 -1
- package/dist/dist.web.js.map +1 -1
- package/dist/src/brdb/bits.d.ts +13 -0
- package/dist/src/brdb/bits.d.ts.map +1 -0
- package/dist/src/brdb/brdb.d.ts +131 -0
- package/dist/src/brdb/brdb.d.ts.map +1 -0
- package/dist/src/brdb/brz.d.ts +51 -0
- package/dist/src/brdb/brz.d.ts.map +1 -0
- package/dist/src/brdb/bytes.d.ts +56 -0
- package/dist/src/brdb/bytes.d.ts.map +1 -0
- package/dist/src/brdb/catalog.d.ts +5 -0
- package/dist/src/brdb/catalog.d.ts.map +1 -0
- package/dist/src/brdb/componentDb.d.ts +8 -0
- package/dist/src/brdb/componentDb.d.ts.map +1 -0
- package/dist/src/brdb/fs.d.ts +16 -0
- package/dist/src/brdb/fs.d.ts.map +1 -0
- package/dist/src/brdb/guid.d.ts +11 -0
- package/dist/src/brdb/guid.d.ts.map +1 -0
- package/dist/src/brdb/index.d.ts +21 -0
- package/dist/src/brdb/index.d.ts.map +1 -0
- package/dist/src/brdb/msgpack.d.ts +23 -0
- package/dist/src/brdb/msgpack.d.ts.map +1 -0
- package/dist/src/brdb/pending.d.ts +11 -0
- package/dist/src/brdb/pending.d.ts.map +1 -0
- package/dist/src/brdb/reader.d.ts +176 -0
- package/dist/src/brdb/reader.d.ts.map +1 -0
- package/dist/src/brdb/schema.d.ts +73 -0
- package/dist/src/brdb/schema.d.ts.map +1 -0
- package/dist/src/brdb/schemaText.d.ts +8 -0
- package/dist/src/brdb/schemaText.d.ts.map +1 -0
- package/dist/src/brdb/schemas.d.ts +4 -0
- package/dist/src/brdb/schemas.d.ts.map +1 -0
- package/dist/src/brdb/world.d.ts +80 -0
- package/dist/src/brdb/world.d.ts.map +1 -0
- package/dist/src/{constants.d.ts → brs/constants.d.ts} +1 -1
- package/dist/src/brs/constants.d.ts.map +1 -0
- package/dist/src/brs/read.d.ts.map +1 -0
- package/dist/src/brs/read.v1.d.ts.map +1 -0
- package/dist/src/brs/read.v10.d.ts.map +1 -0
- package/dist/src/brs/read.v14.d.ts.map +1 -0
- package/dist/src/brs/read.v2.d.ts.map +1 -0
- package/dist/src/brs/read.v3.d.ts.map +1 -0
- package/dist/src/brs/read.v4.d.ts.map +1 -0
- package/dist/src/brs/read.v8.d.ts.map +1 -0
- package/dist/src/brs/read.v9.d.ts.map +1 -0
- package/dist/src/{types.d.ts → brs/types.d.ts} +35 -35
- package/dist/src/brs/types.d.ts.map +1 -0
- package/dist/src/{utils.d.ts → brs/utils.d.ts} +4 -9
- package/dist/src/brs/utils.d.ts.map +1 -0
- package/dist/src/{write.d.ts → brs/write.d.ts} +1 -1
- package/dist/src/brs/write.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/uuid.d.ts +1 -1
- package/dist/src/uuid.d.ts.map +1 -1
- package/package.json +41 -17
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/read.d.ts.map +0 -1
- package/dist/src/read.v1.d.ts.map +0 -1
- package/dist/src/read.v10.d.ts.map +0 -1
- package/dist/src/read.v14.d.ts.map +0 -1
- package/dist/src/read.v2.d.ts.map +0 -1
- package/dist/src/read.v3.d.ts.map +0 -1
- package/dist/src/read.v4.d.ts.map +0 -1
- package/dist/src/read.v8.d.ts.map +0 -1
- package/dist/src/read.v9.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/write.d.ts.map +0 -1
- /package/dist/src/{read.d.ts → brs/read.d.ts} +0 -0
- /package/dist/src/{read.v1.d.ts → brs/read.v1.d.ts} +0 -0
- /package/dist/src/{read.v10.d.ts → brs/read.v10.d.ts} +0 -0
- /package/dist/src/{read.v14.d.ts → brs/read.v14.d.ts} +0 -0
- /package/dist/src/{read.v2.d.ts → brs/read.v2.d.ts} +0 -0
- /package/dist/src/{read.v3.d.ts → brs/read.v3.d.ts} +0 -0
- /package/dist/src/{read.v4.d.ts → brs/read.v4.d.ts} +0 -0
- /package/dist/src/{read.v8.d.ts → brs/read.v8.d.ts} +0 -0
- /package/dist/src/{read.v9.d.ts → brs/read.v9.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# brs.js
|
|
2
2
|
|
|
3
|
-
Read and write Brickadia save files (.brs)
|
|
3
|
+
Read and write Brickadia save files (.brs, .brz)
|
|
4
4
|
|
|
5
|
-
Currently supports save versions
|
|
5
|
+
Currently supports all BRS save versions. BRS Files are no longer supported as of Brickadia EA3.
|
|
6
6
|
|
|
7
|
-
**Warning:**
|
|
7
|
+
**Warning:** **Unreal Engine uses numbers potentially larger than Javascript can handle.**
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -134,47 +134,47 @@ Unsigned ints, while unlikely, may overflow.
|
|
|
134
134
|
|
|
135
135
|
**Fields:** (optional fields during `brs.write(save)` will be set to default)
|
|
136
136
|
|
|
137
|
-
| field | type | default | optional | description
|
|
138
|
-
|
|
139
|
-
| version | short | Latest Save Version | auto | Save file version
|
|
140
|
-
| game_version | int | Game Version | ☑ | Saving version of the game
|
|
141
|
-
| map | string | 'Unknown' | ☑ | Map where the save was generated
|
|
142
|
-
| author.id | uuid | 00000000-0000-0000-0000-000000000000 | ☑ | Save author UUID
|
|
143
|
-
| author.name | string | 'Unknown' | ☑ | Save author name
|
|
144
|
-
| description | string | '' (Empty String) | ☑ | Save author name
|
|
145
|
-
| save_time | array | [0, 0, 0, 0, 0, 0, 0, 0] | ☑ | UTC in bytes of creation time
|
|
146
|
-
| brick_count | int | Number of bricks in `bricks` | auto | Number of bricks in save
|
|
147
|
-
| mods | array | [] | ☑ | In game mods required for load
|
|
148
|
-
| brick_assets | array | ['PB_DefaultBrick'] | ☑ | List of brick assets
|
|
149
|
-
| colors | array | [] | ☑ | List of colorset colors
|
|
150
|
-
| materials | array | ['BMC_Plastic'] | ☑ | List of used materials
|
|
151
|
-
| physical_materials | array | [] | ☑ | List of physical materials
|
|
152
|
-
| brick_owners | array | [{}] | ☑ | Brick owner list
|
|
153
|
-
| brick_owners[].id | uuid | 00000000-0000-0000-0000-000000000000 | ☑ | Brick owner list user uuid
|
|
154
|
-
| brick_owners[].name | string | 'Unknown' | ☑ | Brick owner list user name
|
|
155
|
-
| brick_owners[].display_name | string | 'Unknown' | ☑ | Brick owner list display name
|
|
156
|
-
| preview | array | undefined | ☑ | 1280x720 png screenshot data
|
|
157
|
-
| bricks | array | | | List of bricks in the save
|
|
158
|
-
| bricks[].asset_name_index | int | 0 (0 indexed) | ☑ | Index of asset in `brick_assets`
|
|
159
|
-
| bricks[].size | array | | | Brick size
|
|
160
|
-
| bricks[].position | array | | | Brick position
|
|
161
|
-
| bricks[].direction | int | 4 (Positive Z, Upward) | ☑ | Brick axis / facing direction
|
|
162
|
-
| bricks[].rotation | int | 0 (0 degrees) | ☑ | Brick rotation on axis
|
|
163
|
-
| bricks[].collision | bool | true | ☑ | Brick has collision with players
|
|
164
|
-
| bricks[].collision | object | | ☑ | Brick collision in general
|
|
165
|
-
| bricks[].visibility | bool | true | ☑ | Brick renders to players
|
|
166
|
-
| bricks[].material_index | int | 0 (0 indexed) | ☑ | Index of material in `materials`
|
|
167
|
-
| bricks[].material_intensity | int | 0 (0 indexed) | ☑ | Material intensity (0-10)
|
|
168
|
-
| bricks[].physical_index | int | 0 (0 indexed) | ☑ | Index of physical material
|
|
169
|
-
| bricks[].color
|
|
170
|
-
| bricks[].color
|
|
171
|
-
| bricks[].color
|
|
172
|
-
| bricks[].owner_index | int | 1 (1 indexed) | ☑ | Index of owner in `brick_owners`
|
|
173
|
-
| bricks[].components | object | {} | ☑ | Components on this brick
|
|
174
|
-
| components | object | {} | ☑ | List of components in the save
|
|
175
|
-
| components[].version | int | | | Game version for this component
|
|
176
|
-
| components[].brick_indices | array | | | Indices of assigned bricks
|
|
177
|
-
| components[].properties | object | | | Map of properties names and types|
|
|
137
|
+
| field | type | default | optional | description |
|
|
138
|
+
| --------------------------- | ------ | ------------------------------------ | -------- | --------------------------------- |
|
|
139
|
+
| version | short | Latest Save Version | auto | Save file version |
|
|
140
|
+
| game_version | int | Game Version | ☑ | Saving version of the game |
|
|
141
|
+
| map | string | 'Unknown' | ☑ | Map where the save was generated |
|
|
142
|
+
| author.id | uuid | 00000000-0000-0000-0000-000000000000 | ☑ | Save author UUID |
|
|
143
|
+
| author.name | string | 'Unknown' | ☑ | Save author name |
|
|
144
|
+
| description | string | '' (Empty String) | ☑ | Save author name |
|
|
145
|
+
| save_time | array | [0, 0, 0, 0, 0, 0, 0, 0] | ☑ | UTC in bytes of creation time |
|
|
146
|
+
| brick_count | int | Number of bricks in `bricks` | auto | Number of bricks in save |
|
|
147
|
+
| mods | array | [] | ☑ | In game mods required for load |
|
|
148
|
+
| brick_assets | array | ['PB_DefaultBrick'] | ☑ | List of brick assets |
|
|
149
|
+
| colors | array | [] | ☑ | List of colorset colors |
|
|
150
|
+
| materials | array | ['BMC_Plastic'] | ☑ | List of used materials |
|
|
151
|
+
| physical_materials | array | [] | ☑ | List of physical materials |
|
|
152
|
+
| brick_owners | array | [{}] | ☑ | Brick owner list |
|
|
153
|
+
| brick_owners[].id | uuid | 00000000-0000-0000-0000-000000000000 | ☑ | Brick owner list user uuid |
|
|
154
|
+
| brick_owners[].name | string | 'Unknown' | ☑ | Brick owner list user name |
|
|
155
|
+
| brick_owners[].display_name | string | 'Unknown' | ☑ | Brick owner list display name |
|
|
156
|
+
| preview | array | undefined | ☑ | 1280x720 png screenshot data |
|
|
157
|
+
| bricks | array | | | List of bricks in the save |
|
|
158
|
+
| bricks[].asset_name_index | int | 0 (0 indexed) | ☑ | Index of asset in `brick_assets` |
|
|
159
|
+
| bricks[].size | array | | | Brick size |
|
|
160
|
+
| bricks[].position | array | | | Brick position |
|
|
161
|
+
| bricks[].direction | int | 4 (Positive Z, Upward) | ☑ | Brick axis / facing direction |
|
|
162
|
+
| bricks[].rotation | int | 0 (0 degrees) | ☑ | Brick rotation on axis |
|
|
163
|
+
| bricks[].collision | bool | true | ☑ | Brick has collision with players |
|
|
164
|
+
| bricks[].collision | object | | ☑ | Brick collision in general |
|
|
165
|
+
| bricks[].visibility | bool | true | ☑ | Brick renders to players |
|
|
166
|
+
| bricks[].material_index | int | 0 (0 indexed) | ☑ | Index of material in `materials` |
|
|
167
|
+
| bricks[].material_intensity | int | 0 (0 indexed) | ☑ | Material intensity (0-10) |
|
|
168
|
+
| bricks[].physical_index | int | 0 (0 indexed) | ☑ | Index of physical material |
|
|
169
|
+
| bricks[].color _(colorset)_ | int | 0 | ☑ | Index of color in `colors` |
|
|
170
|
+
| bricks[].color _(rgba)_ | array | [255, 255, 255, 255] | ☑ | Color in RGBA Bytes |
|
|
171
|
+
| bricks[].color _(rgb)_ | array | [255, 255, 255] _(v9+)_ | ☑ | Color in RGBA Bytes |
|
|
172
|
+
| bricks[].owner_index | int | 1 (1 indexed) | ☑ | Index of owner in `brick_owners` |
|
|
173
|
+
| bricks[].components | object | {} | ☑ | Components on this brick |
|
|
174
|
+
| components | object | {} | ☑ | List of components in the save |
|
|
175
|
+
| components[].version | int | | | Game version for this component |
|
|
176
|
+
| components[].brick_indices | array | | | Indices of assigned bricks |
|
|
177
|
+
| components[].properties | object | | | Map of properties names and types |
|
|
178
178
|
|
|
179
179
|
### Function `brs.read(buffer, options)`
|
|
180
180
|
|
|
@@ -182,15 +182,15 @@ Unsigned ints, while unlikely, may overflow.
|
|
|
182
182
|
|
|
183
183
|
In node, the buffer can be obtained from `fs.readFile` without an encoding specified. In web, the buffer can be obtained via `File.arrayBuffer()`. Be sure to resolve promises where necessary.
|
|
184
184
|
|
|
185
|
-
| parameter
|
|
186
|
-
|
|
187
|
-
| `buffer`
|
|
188
|
-
| `options`
|
|
185
|
+
| parameter | type | description |
|
|
186
|
+
| --------- | ------------------- | --------------------------------------- |
|
|
187
|
+
| `buffer` | Uint8Array / Buffer | Input bytes to be parsed |
|
|
188
|
+
| `options` | Object | Options for the parser, see table below |
|
|
189
189
|
|
|
190
190
|
#### Options
|
|
191
191
|
|
|
192
192
|
| name | type | description | default |
|
|
193
|
-
|
|
193
|
+
| --------- | ------- | ------------------------ | ------- |
|
|
194
194
|
| `bricks` | boolean | Whether to read bricks | `true` |
|
|
195
195
|
| `preview` | boolean | Whether to copy previews | `false` |
|
|
196
196
|
|
|
@@ -200,154 +200,235 @@ In node, the buffer can be obtained from `fs.readFile` without an encoding speci
|
|
|
200
200
|
|
|
201
201
|
In node, the buffer can be saved with from `fs.writeFile(fileName, buffer)`. In web, the buffer can be made into a `new Blob([buffer])`, and can be downloaded with an `<a download>` with `href` as `URL.createObjectURL(blob)`.
|
|
202
202
|
|
|
203
|
-
| parameter
|
|
204
|
-
|
|
205
|
-
| `saveObj`
|
|
203
|
+
| parameter | type | description |
|
|
204
|
+
| --------- | ----------- | -------------------------------------- |
|
|
205
|
+
| `saveObj` | Save Object | Save Object to be turned into a buffer |
|
|
206
206
|
|
|
207
207
|
### Brick Assets
|
|
208
208
|
|
|
209
209
|
Notes:
|
|
210
210
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
|
218
|
-
|
|
219
|
-
|
|
|
220
|
-
|
|
|
221
|
-
|
|
|
222
|
-
|
|
|
223
|
-
|
|
|
224
|
-
|
|
|
225
|
-
|
|
|
226
|
-
|
|
|
227
|
-
|
|
|
228
|
-
|
|
|
229
|
-
|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
233
|
-
|
|
|
234
|
-
|
|
|
235
|
-
|
|
|
236
|
-
|
|
|
237
|
-
|
|
|
238
|
-
|
|
|
239
|
-
|
|
|
240
|
-
|
|
|
241
|
-
|
|
|
242
|
-
|
|
|
243
|
-
|
|
|
244
|
-
|
|
|
245
|
-
|
|
|
246
|
-
|
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
|
|
|
251
|
-
|
|
|
252
|
-
|
|
|
253
|
-
|
|
|
254
|
-
|
|
|
255
|
-
|
|
|
256
|
-
|
|
|
257
|
-
|
|
|
258
|
-
|
|
|
259
|
-
|
|
|
260
|
-
|
|
|
261
|
-
|
|
|
262
|
-
|
|
|
263
|
-
|
|
|
264
|
-
|
|
|
265
|
-
|
|
|
266
|
-
|
|
|
267
|
-
|
|
|
268
|
-
|
|
|
269
|
-
|
|
|
270
|
-
|
|
|
271
|
-
|
|
|
272
|
-
|
|
|
273
|
-
|
|
|
274
|
-
|
|
|
275
|
-
|
|
|
276
|
-
|
|
|
277
|
-
|
|
|
278
|
-
|
|
|
279
|
-
|
|
|
280
|
-
|
|
|
281
|
-
|
|
|
282
|
-
|
|
|
283
|
-
|
|
|
284
|
-
|
|
|
285
|
-
|
|
|
286
|
-
|
|
|
287
|
-
|
|
|
288
|
-
|
|
|
289
|
-
|
|
|
290
|
-
|
|
|
291
|
-
|
|
|
292
|
-
|
|
|
293
|
-
|
|
|
294
|
-
|
|
|
295
|
-
|
|
|
296
|
-
|
|
|
297
|
-
|
|
|
298
|
-
|
|
|
299
|
-
|
|
|
300
|
-
|
|
|
301
|
-
|
|
|
302
|
-
|
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
|
306
|
-
|
|
|
307
|
-
|
|
|
308
|
-
|
|
|
309
|
-
|
|
|
310
|
-
|
|
|
311
|
-
|
|
|
312
|
-
|
|
|
313
|
-
|
|
|
314
|
-
|
|
|
315
|
-
|
|
|
316
|
-
|
|
|
317
|
-
|
|
|
318
|
-
|
|
|
319
|
-
|
|
|
320
|
-
|
|
|
321
|
-
|
|
|
322
|
-
|
|
|
323
|
-
|
|
|
324
|
-
|
|
|
325
|
-
|
|
|
326
|
-
|
|
|
327
|
-
|
|
|
328
|
-
|
|
|
329
|
-
|
|
|
330
|
-
|
|
|
331
|
-
|
|
|
332
|
-
|
|
|
333
|
-
|
|
|
334
|
-
|
|
|
335
|
-
|
|
|
336
|
-
|
|
|
337
|
-
|
|
|
338
|
-
|
|
|
339
|
-
|
|
|
340
|
-
|
|
|
341
|
-
|
|
211
|
+
- Size must be [0, 0, 0] for bricks using non-procedural brick assets
|
|
212
|
+
- Size must NOT be [0, 0, 0] for bricks using procedural brick assets
|
|
213
|
+
- 1x1 brick has size [5, 5, 6] and 'PB_DefaultBrick' brick asset
|
|
214
|
+
- 1x1F plate has size [5, 5, 2] and 'PB_DefaultBrick' brick asset
|
|
215
|
+
|
|
216
|
+
| name | procedural |
|
|
217
|
+
| --------------------------------- | ---------- |
|
|
218
|
+
| PB_DefaultBrick | ☑ |
|
|
219
|
+
| PB_DefaultRamp | ☑ |
|
|
220
|
+
| PB_DefaultRampCrest | ☑ |
|
|
221
|
+
| PB_DefaultRampCrestCorner | ☑ |
|
|
222
|
+
| PB_DefaultRampCrestEnd | ☑ |
|
|
223
|
+
| PB_DefaultRampInnerCornerInverted | ☑ |
|
|
224
|
+
| PB_DefaultRampInverted | ☑ |
|
|
225
|
+
| PB_DefaultSideWedge | ☑ |
|
|
226
|
+
| PB_DefaultSideWedgeTile | ☑ |
|
|
227
|
+
| PB_DefaultTile | ☑ |
|
|
228
|
+
| PB_DefaultWedge | ☑ |
|
|
229
|
+
| PB_DefaultMicroBrick | ☑ |
|
|
230
|
+
| PB_DefaultMicroWedge | ☑ |
|
|
231
|
+
| B_1x1_Brick_Side | |
|
|
232
|
+
| B_1x1_Brick_Side_Lip | |
|
|
233
|
+
| B_1x1_Cone | |
|
|
234
|
+
| B_1x1_Round | |
|
|
235
|
+
| B_1x1F_Octo | |
|
|
236
|
+
| B_1x1F_Round | |
|
|
237
|
+
| B_1x2_Overhang | |
|
|
238
|
+
| B_1x2f_Plate_Center | |
|
|
239
|
+
| B_1x2f_Plate_Center_Inv | |
|
|
240
|
+
| B_1x4_Brick_Side | |
|
|
241
|
+
| B_1x_Octo | |
|
|
242
|
+
| B_1x_Octo_90Deg | |
|
|
243
|
+
| B_1x_Octo_90Deg_Inv | |
|
|
244
|
+
| B_1x_Octo_T | |
|
|
245
|
+
| B_1x_Octo_T_Inv | |
|
|
246
|
+
| B_2x1_Slipper | |
|
|
247
|
+
| B_2x2_Cone | |
|
|
248
|
+
| B_2x2_Corner | |
|
|
249
|
+
| B_2x2_Overhang | |
|
|
250
|
+
| B_2x2_Round | |
|
|
251
|
+
| B_2x2_Slipper | |
|
|
252
|
+
| B_2x2F_Octo | |
|
|
253
|
+
| B_2x2F_Octo_Converter | |
|
|
254
|
+
| B_2x2F_Octo_Converter_Inv | |
|
|
255
|
+
| B_2x2f_Plate_Center | |
|
|
256
|
+
| B_2x2f_Plate_Center_Inv | |
|
|
257
|
+
| B_2x2F_Round | |
|
|
258
|
+
| B_2x4_Door_Frame | |
|
|
259
|
+
| B_2x_Cube_Side | |
|
|
260
|
+
| B_2x_Octo | |
|
|
261
|
+
| B_2x_Octo_90Deg | |
|
|
262
|
+
| B_2x_Octo_90Deg_Inv | |
|
|
263
|
+
| B_2x_Octo_Cone | |
|
|
264
|
+
| B_2x_Octo_T | |
|
|
265
|
+
| B_2x_Octo_T_Inv | |
|
|
266
|
+
| B_4x4_Round | |
|
|
267
|
+
| B_8x8_Lattice_Plate | |
|
|
268
|
+
| B_Bishop | |
|
|
269
|
+
| B_Bone | |
|
|
270
|
+
| B_BoneStraight | |
|
|
271
|
+
| B_Branch | |
|
|
272
|
+
| B_Bush | |
|
|
273
|
+
| B_Cauldron | |
|
|
274
|
+
| B_Chalice | |
|
|
275
|
+
| B_CheckPoint | |
|
|
276
|
+
| B_Coffin | |
|
|
277
|
+
| B_Coffin_Lid | |
|
|
278
|
+
| B_Fern | |
|
|
279
|
+
| B_Flame | |
|
|
280
|
+
| B_Flower | |
|
|
281
|
+
| B_Gravestone | |
|
|
282
|
+
| B_GoalPoint | |
|
|
283
|
+
| B_Handle | |
|
|
284
|
+
| B_Hedge_1x1 | |
|
|
285
|
+
| B_Hedge_1x1_Corner | |
|
|
286
|
+
| B_Hedge_1x2 | |
|
|
287
|
+
| B_Hedge_1x4 | |
|
|
288
|
+
| B_Inverted_Cone | |
|
|
289
|
+
| B_Jar | |
|
|
290
|
+
| B_King | |
|
|
291
|
+
| B_Knight | |
|
|
292
|
+
| B_Ladder | |
|
|
293
|
+
| B_Pawn | |
|
|
294
|
+
| B_Picket_Fence | |
|
|
295
|
+
| B_Pine_Tree | |
|
|
296
|
+
| B_Pumpkin | |
|
|
297
|
+
| B_Pumpkin_Carved | |
|
|
298
|
+
| B_Queen | |
|
|
299
|
+
| B_Rook | |
|
|
300
|
+
| B_Sausage | |
|
|
301
|
+
| B_Small_Flower | |
|
|
302
|
+
| B_SpawnPoint | |
|
|
303
|
+
| B_Swirl_Plate | |
|
|
304
|
+
| B_Turkey_Body | |
|
|
305
|
+
| B_Turkey_Leg | |
|
|
306
|
+
| B_1x1_Gate_Constant | |
|
|
307
|
+
| B_1x1_Gate_Subtract | |
|
|
308
|
+
| B_1x1_Gate_Multiply | |
|
|
309
|
+
| B_1x1_Gate_ModFloored | |
|
|
310
|
+
| B_1x1_Gate_Mod | |
|
|
311
|
+
| B_1x1_Gate_Divide | |
|
|
312
|
+
| B_1x1_Gate_Blend | |
|
|
313
|
+
| B_1x1_Gate_Add | |
|
|
314
|
+
| B_1x1_Gate_XOR | |
|
|
315
|
+
| B_1x1_Gate_OR | |
|
|
316
|
+
| B_1x1_Gate_NOR | |
|
|
317
|
+
| B_1x1_Gate_NAND | |
|
|
318
|
+
| B_1x1_Gate_EdgeDetector | |
|
|
319
|
+
| B_1x1_Gate_Floor | |
|
|
320
|
+
| B_1x1_Gate_Ceiling | |
|
|
321
|
+
| B_1x1_EntityGate_ReadBrickGrid | |
|
|
322
|
+
| B_1x1_Gate_NotEqual | |
|
|
323
|
+
| B_1x1_Gate_LessThanEqual | |
|
|
324
|
+
| B_1x1_Gate_LessThan | |
|
|
325
|
+
| B_1x1_Gate_GreaterThanEqual | |
|
|
326
|
+
| B_1x1_Gate_GreaterThan | |
|
|
327
|
+
| B_1x1_Gate_XOR_Bitwise | |
|
|
328
|
+
| B_1x1_Gate_ShiftRight_Bitwise | |
|
|
329
|
+
| B_1x1_Gate_ShiftLeft_Bitwise | |
|
|
330
|
+
| B_1x1_Gate_OR_Bitwise | |
|
|
331
|
+
| B_1x1_Gate_NOR_Bitwise | |
|
|
332
|
+
| B_1x1_Gate_NAND_Bitwise | |
|
|
333
|
+
| B_1x1_Gate_AND_Bitwise | |
|
|
334
|
+
| B_1x1_Reroute_Node | |
|
|
335
|
+
| B_1x1_Gate_Timer_Tick | |
|
|
336
|
+
| B_1x1_Gate_Timer | |
|
|
337
|
+
| B_1x1_NOT_Gate | |
|
|
338
|
+
| B_1x1_Gate_AND | |
|
|
339
|
+
| B_1x1_Gate_Equal | |
|
|
340
|
+
| B_1x1_Gate_NOT_Bitwise | |
|
|
341
|
+
|
|
342
|
+
## Brickadia Worlds (.brz)
|
|
343
|
+
|
|
344
|
+
brs-js can write and read the Brickadia World archive format (`.brz`).
|
|
345
|
+
Writing covers bricks, components, and wires; entities can be read but not
|
|
346
|
+
yet written. `writeBrzLegacy` converts the same legacy `WriteSaveObject`
|
|
347
|
+
that `write()` takes, except that `components` on bricks is a modern typed
|
|
348
|
+
array (the legacy .brs component map is not converted) and `wires` on the
|
|
349
|
+
save uses modern component and port names. A builder-style world API for
|
|
350
|
+
authoring saves from scratch is planned:
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
import { writeBrzLegacy, WorldReader } from 'brs-js';
|
|
354
|
+
|
|
355
|
+
const brz = writeBrzLegacy({
|
|
356
|
+
description: 'my world',
|
|
357
|
+
bricks: [{ size: [5, 5, 6], position: [0, 0, 6], color: [255, 0, 0] }],
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// WorldReader is lazy: schemas are parsed once and cached, and chunk
|
|
361
|
+
// payloads are only decoded when you ask for them.
|
|
362
|
+
const world = WorldReader.from(brz);
|
|
363
|
+
world.bundle(); // Meta/Bundle.json
|
|
364
|
+
world.brickAssets(); // basic asset names followed by procedural
|
|
365
|
+
world.brickOwners(); // owner rows (PUBLIC excluded)
|
|
366
|
+
world.gridIds(); // [1] plus any entity sub-grids
|
|
367
|
+
for (const brick of world.bricks()) {
|
|
368
|
+
// decoded chunk by chunk
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Blobs are stored uncompressed by default, which is valid and matches the
|
|
373
|
+
reference implementation byte for byte. To compress with zstd (Node 22.15
|
|
374
|
+
or newer):
|
|
375
|
+
|
|
376
|
+
```js
|
|
377
|
+
import { zstdCompressSync, constants } from 'node:zlib';
|
|
378
|
+
const brz = writeBrzLegacy(save, {
|
|
379
|
+
compress: data =>
|
|
380
|
+
zstdCompressSync(data, {
|
|
381
|
+
params: { [constants.ZSTD_c_compressionLevel]: 14 },
|
|
382
|
+
}),
|
|
383
|
+
});
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Reading applies a few normalizations:
|
|
387
|
+
|
|
388
|
+
- Brick order round-trips per chunk rather than in global save order.
|
|
389
|
+
- `collision.tool` always reads `true` because the format does not store it.
|
|
390
|
+
- Palette color indices are resolved to `[r, g, b]` at write time.
|
|
391
|
+
- `save.map` is not mapped; pass `{ environment }` in the options instead.
|
|
392
|
+
|
|
393
|
+
The cross-language fixture tests skip unless fixtures have been generated.
|
|
394
|
+
To enable them, run `just fixtures` with a crate checkout at `../brdb` (or
|
|
395
|
+
set `BRDB_CRATE`).
|
|
396
|
+
|
|
397
|
+
### .brdb (SQLite worlds)
|
|
398
|
+
|
|
399
|
+
`.brdb` is the game's live world format: the same virtual filesystem as
|
|
400
|
+
`.brz`, stored in SQLite with full revision history. Reading and writing
|
|
401
|
+
requires `better-sqlite3` (an optional peer dependency, node only):
|
|
402
|
+
|
|
403
|
+
npm install better-sqlite3
|
|
404
|
+
|
|
405
|
+
```js
|
|
406
|
+
import { Brdb } from 'brs-js';
|
|
407
|
+
|
|
408
|
+
const db = await Brdb.open('MyWorld.brdb');
|
|
409
|
+
const reader = db.worldReader(); // same surface as WorldReader.from(brz)
|
|
410
|
+
for (const brick of reader.bricks()) console.log(brick.position);
|
|
411
|
+
|
|
412
|
+
const out = await Brdb.create('New.brdb');
|
|
413
|
+
out.save('initial save', {
|
|
414
|
+
bricks: [{ size: [5, 5, 6], position: [0, 0, 6] }],
|
|
415
|
+
});
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Every `save`/`writePending` call is one revision: unchanged files are shared,
|
|
419
|
+
changed files are soft-deleted and reinserted, and blobs are deduplicated by
|
|
420
|
+
BLAKE3 hash. Blobs compress with zstd level 14 when node's zlib supports it
|
|
421
|
+
(pass `compress: null` to store raw). Advanced: `new Brdb(db)` wraps any
|
|
422
|
+
SQLite handle with a compatible synchronous API, with no dependency at all.
|
|
342
423
|
|
|
343
424
|
## Development
|
|
344
425
|
|
|
345
426
|
NPM Scripts (`npm run <cmd>`)
|
|
346
427
|
|
|
347
|
-
| name
|
|
348
|
-
|
|
349
|
-
| build
|
|
350
|
-
| watch
|
|
351
|
-
| dist
|
|
352
|
-
| test
|
|
353
|
-
|
|
428
|
+
| name | description |
|
|
429
|
+
| ---------- | ---------------------------------------------------- |
|
|
430
|
+
| build | Build all targets (web + node) and type declarations |
|
|
431
|
+
| watch | Rebuild the library when files change |
|
|
432
|
+
| dist | Alias for `build` |
|
|
433
|
+
| test | Run the test suite once |
|
|
434
|
+
| test:watch | Run the test suite in watch mode |
|