Author Topic: [WIP] [RESOURCE?] .bls file format documentation  (Read 2122 times)

A single brick in a .bls save file:

2x4" 3.5 2 1.1 0 0 16 0 0 1 1 1
+-OWNER 27690
+-EVENT   0 1 onActivate 0 Self disappear 5         
+-EMITTER Brick Explosion" 2
+-LIGHT Blue Fire Light" 1
+-ITEM Multitool" 2 2 4000

What does all of that text mean? :O

Fear not of confusing strings!
Here is my current understanding of the format (in an easy to read table!)

Brick Data:
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Brick UIName
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Position
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Angle ID
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Is Baseplate
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Color ID
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Print ID (an empty space unless the brick has a print in it)
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Color FX ID
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Shape FX ID
2x4" 3.5 2 1.1 0 0 16 * 0 0 1 1 1 - Raycasting, Colliding, and Rendering, respectively

Owner Data:
+-OWNER 27690 - Field name (owner)
+-OWNER 27690 - Owner's BL_ID

Event Data:
+-EVENT 0 1 onActivate 0 Self disappear 5 - Field name (event)
+-EVENT 0 1 onActivate 0 Self disappear 5 - Event Delay
+-EVENT 0 1 onActivate 0 Self disappear 5 - Event Enabled
+-EVENT 0 1 onActivate 0 Self disappear 5 - Event Input
+-EVENT 0 1 onActivate 0 Self disappear 5 - Unknown
+-EVENT 0 1 onActivate 0 Self disappear 5 - Event Target
+-EVENT 0 1 onActivate 0 Self disappear 5 - Event Output
+-EVENT 0 1 onActivate 0 Self disappear 5 - Event Output Field

Emitter Data:
+-EMITTER Brick Explosion" 2 - Field name (emitter)
+-EMITTER Brick Explosion" 2 - Emitter UIName
+-EMITTER Brick Explosion" 2 - Direction

Light Data:
+-LIGHT Blue Fire Light" 1 - Field name (light)
+-LIGHT Blue Fire Light" 1 - Light UIName
+-LIGHT Blue Fire Light" 1 - Unknown

Item Data:
+-ITEM Multitool" 2 2 4000 - Field name (item)
+-ITEM Multitool" 2 2 4000 - Item UIName
+-ITEM Multitool" 2 2 4000 - Direction
+-ITEM Multitool" 2 2 4000 - Position
+-ITEM Multitool" 2 2 4000 - Item Respawn Time


Reading the .bls format and outputting to variables
This took some complex string works with both me and Redoctober's work being put into this.

Example: A demo function that would load bricks from a save file specified in %filePath
Code: [Select]
function loadFromFile(%filePath)
{
%file = new FileObject();
%file.openForRead(%filePath);

while(!%file.isEoF())
{
%line = %file.readLine();

if(strPos(%line, "\"") != -1 && getSubStr(%line, 0, 2) !$= "+-")
{
%index = strpos(%line, "\" ");
%params = getSubStr(%line, %index + 2, strlen(%line));

%brick = new fxDTSBrick()
{
dataBlock = uiNameToBrickData(getSubStr(%line, 0, %index));
pos = getWords(%params, 0, 2);
angleID = getWord(%params, 3);
rotation = rotationFromAngleID(%angleID);
isBasePlate = getWord(%params, 4);
colorID = getWord(%params, 5);
colorFX = getWord(%params, 7);
shapeFX = getWord(%params, 8);
isRaycasting = getWord(%params, 9);
isColliding = getWord(%params, 10);
isRendering = getWord(%params, 11);
isPlanted = 1;
};

%error = %brick.plant();

if(%error == 1 || %error == 5 || %error == 3)
{
%brick.delete();
}

if(isObject(%brick))
{
%brick.setTrusted(1);
BrickGroup_888888.add(%brick);

%brick.setRendering(%brick.isRendering);
%brick.setRayCasting(%brick.isRaycasting);
%brick.setColliding(%brick.isColliding);
%brick.setColorFX(%brick.colorFX);
}
}
}
}

function rotationFromAngleID(%angle)
{
switch(%angle)
{
case 0:
%rotation = "1 0 0 0";
case 1:
%rotation = "0 0 1 90";
case 2:
%rotation = "0 0 1 180";
default:
%rotation = "0 0 -1 90";
}
return %rotation;
}

function uiNameToBrickData(%string)
{
return(isObject(%data = $uiNameTable[%string]) ? %data : -1);
}

Thanks to Pie Crust for providing sample brick data.
« Last Edit: December 28, 2016, 05:43:43 PM by Darksaber2213 »

Stuff is missing.

Description.
Colorset.
Owner.
Items and junk.
Etc.

Stuff is missing.

Description.
Colorset.
Owner.
Items and junk.
Etc.

I will add these eventually when I figure them out. It should be soon.

Code: [Select]
2x4" -18.25 16.75 0.3 0 1 32  0 0 1 1 1
+-EMITTER Smoke A" 0
+-OWNER 27690
+-EVENT 0 1 onActivate 0 Client ChatMessage This is an event!

... print name, after the color ID

... print name, after the color ID
It depends. Look here.

Code: [Select]
1x1 Print" -37.75 -25.25 0.3 0 1 38 1x1/Square 0 0 1 1 1
+-OWNER 27690
+-EVENT 0 1 onActivate 0 Self disappear 5
+-EMITTER Brick Explosion" 2
+-LIGHT Blue Fire Light" 1
+-ITEM Multitool" 2 2 4000
1x1" -36.75 -25.25 0.3 3 1 38  0 0 1 1 1
+-OWNER 27690

The print is shown only when the brick datablock is a print.

it's interesting to know about



Two spaces for empty print strings. Look closely.

[im g]http://i.imgur.com/vZnLJ1G.png[/img]

Two spaces for empty print strings. Look closely.
Code: [Select]
1x1 Print" -37.75 -25.25 0.3 0 1 38 1x1/Square 0 0 1 1 1
+-OWNER 27690
+-EVENT 0 1 onActivate 0 Self disappear 5
+-EMITTER Brick Explosion" 2
+-LIGHT Blue Fire Light" 1
+-ITEM Multitool" 2 2 4000
1x1" -36.75 -25.25 0.3 3 1 38 @ 0 0 1 1 1
+-OWNER 27690
You're right. I shoved a @ in the empty space.

Updated OP with more deciphered data. If anyone know what the unknown values stand for, please post here.

%string = getSafeVariableName(%string);

That will fix some UI look ups that can get complicated such as "Visolator's rekt-tron" which this will replace as VisolatorAPOS_rektDASHtron

the first section in a .bls is the description

right after indicates # of description lines, including new-lines.

right after that (separated by a new-line) is the colorset used when the build was saved. just multiply every value by 256 and you should get a number very close to an integer that represents the original RGBA color value.

linecount indicates brickcount (aka number of "lines" of brick descriptions, ignoring +- lines which are attached to the brick above them)



given how events are saved here, ive always wondered if there could be some sort of GUI or something that allows people to type in events, or use keyboard keys to quickly bring up certain events, like how you can type "T" when selecting a font in Word, and it automatically jumps you to the "T" section. too often i find clicking all the things really slow.

given how events are saved here, ive always wondered if there could be some sort of GUI or something that allows people to type in events, or use keyboard keys to quickly bring up certain events, like how you can type "T" when selecting a font in Word, and it automatically jumps you to the "T" section. too often i find clicking all the things really slow.
This would be amazing. It should be like visual studio/eclipse etc where it can auto complete the events and provide other suggestions.

It would be cool if someone made a client addon where we type the events in a notepad, load them ingame and put them in a brick. Easy eventing yo. Would be even better if it was all ingame though.