Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Brickadia save file parsing library

License

NotificationsYou must be signed in to change notification settings

Meshiest/brs-js

Repository files navigation

Read and write Brickadia save files (.brs)

Currently supports save versions <= 10

Warning:Unreal Engine uses numbers potentially larger than Javascript can handle.

Install

npm install brs-js

Documentation and Usage

Node:

const brs = require('brs-js');

ES6:

import brs from 'brs-js';

Web:

Head:<script src="https://cdn.jsdelivr.net/npm/brs-js/dist/dist.js"></script>

Script:window.BRS

Examples

Examples are available in theexamples/ directory. All.js examples are for node,.html are for web.

Save Object

The Save Object is the input and output of this program. It represents the decoded/decompressed contents of the save.Strings can be UCS-2 or UTF-8. UUIDs follow the spec. Thesave_time field is 8 bytes (Little Endian) instead of a long.Unsigned ints, while unlikely, may overflow.

{version:short,map:string,author:{id:uuid,name:string},host:{id:uuid,name:string}// (v8+ only)description:string,save_time:UTCas8bytes,brick_count:int,mods:stringarray,brick_assets:[string],// --- See bottom of page for known bricks ---colors:[[byte,byte,byte,byte], ...],physical_materials:[string],// BPMC_Defaultmaterials:[string],// --- Known available materials// BMC_Ghost// BMC_Ghost_Fail// BMC_Plastic// BMC_Glass// BMC_TranslucentPlastic// BMC_Glow// BMC_Metallic// BMC_Hologrambrick_owners:[{id:uuid,name:string,displayName:string,// (v14+ only)bricks:int// (v8+ only)}, ...],components:{[componentName]:{version:int,brick_indices:[int, ...],properties:{[name]:[value], ...},},    ...},wires:[{source:{component:string,// component namebrick_index:int,// index of the brick in `bricks`port:string,// port name},target:{component:string,// component namebrick_index:int,// index of the brick in `bricks`port:string,// port name},}]bricks:[{asset_name_index:int,size:[uint,uint,uint],// must be [0, 0, 0] for all B_ prefixed brick_assets// must NOT be [0, 0, 0] for all PB_ prefixed brick_assets// 1x1 brick has size [5, 5, 6]// 1x1F plate has size [5, 5, 2]position:[int,int,int],direction:0-5,// --- Directions (facing axis) ---// 0: X Positive// 1: X Negative// 2: Y Positive// 3: Y Negative// 4: Z Positive// 5: Z Negativerotation:0-3,// --- Rotations (along the facing axis) ---// 0: 0 Deg// 1: 90 Deg// 2: 180 Deg// 3: 270 Degcollision:{player:bool,weapon:bool,interaction:bool,tool:bool,physics:bool,// disable physics collision},// or boolvisibility:bool,material_index:uint,physical_index:uint,material_intensity:0-10,color:uintor[byte,byte,byte,byte]or(v9)->[byte,byte,byte],owner_index:uint,components:{[componentName]:{[propName]:[propVal],        ...},      ...},}, ...],}

Fields: (optional fields duringbrs.write(save) will be set to default)

fieldtypedefaultoptionaldescription
versionshortLatest Save VersionautoSave file version
game_versionintGame VersionSaving version of the game
mapstring'Unknown'Map where the save was generated
author.iduuid00000000-0000-0000-0000-000000000000Save author UUID
author.namestring'Unknown'Save author name
descriptionstring'' (Empty String)Save author name
save_timearray[0, 0, 0, 0, 0, 0, 0, 0]UTC in bytes of creation time
brick_countintNumber of bricks inbricksautoNumber of bricks in save
modsarray[]In game mods required for load
brick_assetsarray['PB_DefaultBrick']List of brick assets
colorsarray[]List of colorset colors
materialsarray['BMC_Plastic']List of used materials
physical_materialsarray[]List of physical materials
brick_ownersarray[{}]Brick owner list
brick_owners[].iduuid00000000-0000-0000-0000-000000000000Brick owner list user uuid
brick_owners[].namestring'Unknown'Brick owner list user name
brick_owners[].display_namestring'Unknown'Brick owner list display name
previewarrayundefined1280x720 png screenshot data
bricksarrayList of bricks in the save
bricks[].asset_name_indexint0 (0 indexed)Index of asset inbrick_assets
bricks[].sizearrayBrick size
bricks[].positionarrayBrick position
bricks[].directionint4 (Positive Z, Upward)Brick axis / facing direction
bricks[].rotationint0 (0 degrees)Brick rotation on axis
bricks[].collisionbooltrueBrick has collision with players
bricks[].collisionobjectBrick collision in general
bricks[].visibilitybooltrueBrick renders to players
bricks[].material_indexint0 (0 indexed)Index of material inmaterials
bricks[].material_intensityint0 (0 indexed)Material intensity (0-10)
bricks[].physical_indexint0 (0 indexed)Index of physical material
bricks[].color(colorset)int0Index of color incolors
bricks[].color(rgba)array[255, 255, 255, 255]Color in RGBA Bytes
bricks[].color(rgb)array[255, 255, 255](v9+)Color in RGBA Bytes
bricks[].owner_indexint1 (1 indexed)Index of owner inbrick_owners
bricks[].componentsobject{}Components on this brick
componentsobject{}List of components in the save
components[].versionintGame version for this component
components[].brick_indicesarrayIndices of assigned bricks
components[].propertiesobjectMap of properties names and types

Functionbrs.read(buffer, options)

Returns: Save Object

In node, the buffer can be obtained fromfs.readFile without an encoding specified. In web, the buffer can be obtained viaFile.arrayBuffer(). Be sure to resolve promises where necessary.

parametertypedescription
bufferUint8Array / BufferInput bytes to be parsed
optionsObjectOptions for the parser, see table below

Options

nametypedescriptiondefault
bricksbooleanWhether to read brickstrue
previewbooleanWhether to copy previewsfalse

Functionbrs.write(saveObj)

Returns: Uint8Array

In node, the buffer can be saved with fromfs.writeFile(fileName, buffer). In web, the buffer can be made into anew Blob([buffer]), and can be downloaded with an<a download> withhref asURL.createObjectURL(blob).

parametertypedescription
saveObjSave ObjectSave Object to be turned into a buffer

Brick Assets

Notes:

  • Size must be [0, 0, 0] for bricks using non-procedural brick assets
  • Size must NOT be [0, 0, 0] for bricks using procedural brick assets
  • 1x1 brick has size [5, 5, 6] and 'PB_DefaultBrick' brick asset
  • 1x1F plate has size [5, 5, 2] and 'PB_DefaultBrick' brick asset
nameprocedural
PB_DefaultBrick
PB_DefaultRamp
PB_DefaultRampCrest
PB_DefaultRampCrestCorner
PB_DefaultRampCrestEnd
PB_DefaultRampInnerCornerInverted
PB_DefaultRampInverted
PB_DefaultSideWedge
PB_DefaultSideWedgeTile
PB_DefaultTile
PB_DefaultWedge
PB_DefaultMicroBrick
PB_DefaultMicroWedge
B_1x1_Brick_Side
B_1x1_Brick_Side_Lip
B_1x1_Cone
B_1x1_Round
B_1x1F_Octo
B_1x1F_Round
B_1x2_Overhang
B_1x2f_Plate_Center
B_1x2f_Plate_Center_Inv
B_1x4_Brick_Side
B_1x_Octo
B_1x_Octo_90Deg
B_1x_Octo_90Deg_Inv
B_1x_Octo_T
B_1x_Octo_T_Inv
B_2x1_Slipper
B_2x2_Cone
B_2x2_Corner
B_2x2_Overhang
B_2x2_Round
B_2x2_Slipper
B_2x2F_Octo
B_2x2F_Octo_Converter
B_2x2F_Octo_Converter_Inv
B_2x2f_Plate_Center
B_2x2f_Plate_Center_Inv
B_2x2F_Round
B_2x4_Door_Frame
B_2x_Cube_Side
B_2x_Octo
B_2x_Octo_90Deg
B_2x_Octo_90Deg_Inv
B_2x_Octo_Cone
B_2x_Octo_T
B_2x_Octo_T_Inv
B_4x4_Round
B_8x8_Lattice_Plate
B_Bishop
B_Bone
B_BoneStraight
B_Branch
B_Bush
B_Cauldron
B_Chalice
B_CheckPoint
B_Coffin
B_Coffin_Lid
B_Fern
B_Flame
B_Flower
B_Gravestone
B_GoalPoint
B_Handle
B_Hedge_1x1
B_Hedge_1x1_Corner
B_Hedge_1x2
B_Hedge_1x4
B_Inverted_Cone
B_Jar
B_King
B_Knight
B_Ladder
B_Pawn
B_Picket_Fence
B_Pine_Tree
B_Pumpkin
B_Pumpkin_Carved
B_Queen
B_Rook
B_Sausage
B_Small_Flower
B_SpawnPoint
B_Swirl_Plate
B_Turkey_Body
B_Turkey_Leg
B_1x1_Gate_Constant
B_1x1_Gate_Subtract
B_1x1_Gate_Multiply
B_1x1_Gate_ModFloored
B_1x1_Gate_Mod
B_1x1_Gate_Divide
B_1x1_Gate_Blend
B_1x1_Gate_Add
B_1x1_Gate_XOR
B_1x1_Gate_OR
B_1x1_Gate_NOR
B_1x1_Gate_NAND
B_1x1_Gate_EdgeDetector
B_1x1_Gate_Floor
B_1x1_Gate_Ceiling
B_1x1_EntityGate_ReadBrickGrid
B_1x1_Gate_NotEqual
B_1x1_Gate_LessThanEqual
B_1x1_Gate_LessThan
B_1x1_Gate_GreaterThanEqual
B_1x1_Gate_GreaterThan
B_1x1_Gate_XOR_Bitwise
B_1x1_Gate_ShiftRight_Bitwise
B_1x1_Gate_ShiftLeft_Bitwise
B_1x1_Gate_OR_Bitwise
B_1x1_Gate_NOR_Bitwise
B_1x1_Gate_NAND_Bitwise
B_1x1_Gate_AND_Bitwise
B_1x1_Reroute_Node
B_1x1_Gate_Timer_Tick
B_1x1_Gate_Timer
B_1x1_NOT_Gate
B_1x1_Gate_AND
B_1x1_Gate_Equal
B_1x1_Gate_NOT_Bitwise

Development

NPM Scripts (npm run <cmd>)

namedescription
buildBuild library in development mode
watchAuto-build library in development mode when files change
distBuild library in production mode
testRun tests

About

Brickadia save file parsing library

Topics

Resources

License

Stars

Watchers

Forks

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp