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
%filePathfunction 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.