Author Topic: BLS Format?  (Read 825 times)

Don't know if this is the right section or not, I just want a bit of explanation on the BLS format.

Namely the plethora of floats at the top of the save, also the number on the second line.

The saving system has always been kind of an enigma. It's almost totally inaccessible code wise and how it works is a guessing game, so dedicated auto-saving has always been off limits.

The saving system has always been kind of an enigma. It's almost totally inaccessible code wise and how it works is a guessing game, so dedicated auto-saving has always been off limits.
everything but all them thingies at the top seems pretty self-explanatory though.

Code: [Select]
function saveDRPGBricks(%events,%ownership)
{
%path = "config/server/temp/temp.bls";
if(!isWriteableFileName(%path))
{
return;
}
%file = new FileObject();
%file.openForWrite(%path);
%file.writeLine("This is a Blockland save file.  You probably shouldn't modify it cause you'll screw it up.");
%file.writeLine("1"); // What does this mean?
%file.writeLine(%desc);
for(%i=0;%i<64;%i++)
%file.writeLine(getColorIDTable(%i));
%bricks = 0;
for(%i=0;%i<mainBrickGroup.getCount();%i++)
%bricks += mainBrickGroup.getObject(%i).getCount();
%file.writeLine("Linecount " @ %bricks);
for(%d=0;%d<2;%d++)
{
for(%i=0;%i<mainBrickGroup.getCount();%i++)
{
%group = mainBrickGroup.getObject(%i);
for(%a=0;%a<%group.getCount();%a++)
{
%brick = %group.getObject(%a);
if(!(%d ^ %brick.isBasePlate()))
continue;
if(%brick.getDataBlock().hasPrint)
{
%texture = getPrintTexture(%brick.getPrintId());
%path = filePath(%texture);
%underscorePos = strPos(%path, "_");
%name = getSubStr(%path, %underscorePos + 1, strPos(%path, "_", 14) - 14) @ "/" @ fileBase(%texture);
if($printNameTable[%name] !$= "")
{
%print = %name;
}
}
%file.writeLine(%brick.getDataBlock().uiName @ "\" " @ %brick.getPosition() SPC %brick.getAngleID() SPC %brick.isBasePlate() SPC %brick.getColorID() SPC %print SPC %brick.getColorFXID() SPC %brick.getShapeFXID() SPC %brick.isRayCasting() SPC %brick.isColliding() SPC %brick.isRendering());
if(%ownership && %brick.isBasePlate() && !$Server::LAN)
%file.writeLine("+-OWNER " @ getBrickGroupFromObject(%brick).bl_id);
if(%events)
{
if(%brick.getName() !$= "")
%file.writeLine("+-NTOBJECTNAME " @ %brick.getName());
for(%b=0;%b<%brick.numEvents;%b++)
{
%targetClass = %brick.eventTargetIdx[%b] >= 0 ? getWord(getField($InputEvent_TargetListfxDTSBrick_[%brick.eventInputIdx[%b]], %brick.eventTargetIdx[%b]), 1) : "fxDtsBrick";
%paramList = $OutputEvent_parameterList[%targetClass, %brick.eventOutputIdx[%b]];
%params = "";
for(%c=0;%c<4;%c++)
{
if(firstWord(getField(%paramList, %c)) $= "dataBlock" && isObject(%brick.eventOutputParameter[%b, %c + 1]))
%params = %params TAB %brick.eventOutputParameter[%b, %c + 1];
else
%params = %params TAB %brick.eventOutputParameter[%b, %c + 1];
}
%file.writeLine("+-EVENT" TAB %b TAB %brick.eventEnabled[%b] TAB %brick.eventInput[%b] TAB %brick.eventDelay[%b] TAB %brick.eventTarget[%b] TAB %brick.eventNT[%b] TAB %brick.eventOutput[%b] @ %params);
}
}
if(isObject(%brick.emitter))
%file.writeLine("+-EMITTER " @ %brick.emitter.emitter.uiName @ "\" " @ %brick.emitterDirection);
if(%brick.getLightID() >= 0)
%file.writeLine("+-LIGHT " @ %brick.getLightID().getDataBlock().uiName @ "\" "); // Not sure if something else comes after the name
if(isObject(%brick.item))
%file.writeLine("+-ITEM " @ %brick.item.getDataBlock().uiName @ "\" " @ %brick.itemPosition SPC %brick.itemDirection SPC %brick.itemRespawnTime);
if(isObject(%brick.audioEmitter))
%file.writeLine("+-AUDIOEMITTER " @ %brick.audioEmitter.getProfileID().uiName @ "\" "); // Not sure if something else comes after the name
if(isObject(%brick.vehicleSpawnMarker))
%file.writeLine("+-VEHICLE " @ %brick.vehicleSpawnMarker.uiName @ "\" " @ %brick.reColorVehicle);
}
}
}
%file.close();
%file.delete();
fileCopy("config/server/temp/temp.bls","base/server/temp/temp.bls");
return %bricks;
}

Saves the bricks and returns the bricks it saves
arguments are self explanatory.
If you can read it, you can see which stuff is wwhat.

Ah ok, the numbers are the colourset, that makes sense.

Thanks.

I wish the saving system could be more easily extended, so I could include a way to save datablocks and things in it like how colorsets are saved.

I hate loading old saves and seeing hundreds of bricks missing and things turning red when you click them.