I'd suggest creating a custom brick group(a sim object. Don't forget to add it to mainBrickGroup. Dump a brick group to see the fields you should fill when you make it) and then directing $LoadingBricks_BrickGroup to your brick group. You can then use %group.chainDeleteAll(); to delete all of the bricks in your brick group(you might want to write your own method of chain deleting the bricks if you want it to be really efficient, because chainDeleteAll could be improved).
I've created a brickgroup $brick_group named BrickGroup_1337 and I've directed $LoadingBricks_BrickGroup to my brick group though:
$LoadingBricks_BrickGroup = BrickGroup_1337;
When I execute my code, I can type echo($LoadingBricks_BrickGroup.getName()); and it gives me BrickGroup_1337 as expected. However, after loading in a save, I repeat that command and it gives me BrickGroup_999999, as if it overwrote the variable before it even started loading bricks. The bricks loaded in are also part of BrickGroup_999999, and not BrickGroup_1337.
Here is my entire code that I've been using to test this:
$brick_group = new SimGroup(BrickGroup_1337) {
bl_id = "0";
isPublicDomain = "0";
};
mainBrickGroup.add($brick_group);
$LoadingBricks_BrickGroup = BrickGroup_1337;
function serverCmdDeleteGroup(%client) {
$brick_group.chainDeleteAll();
}
Do you have any ideas of what might be causing this?