Author Topic: Unloading a group of bricks loaded in with serverDirectSaveFileLoad  (Read 1227 times)

So my problem is as follows:

I'm loading in a small group of bricks with serverDirectSaveFileLoad with an offset, and I want to be able to unload that small group of bricks without needing to individually delete each loaded brick.

It would be great if there was a way for me to get an array of the objectIDs for the bricks I've loaded in, but as far as I can tell there isn't a built-in way to accomplish this.

What do you guys suggest for this? For my project, I have to load and unload bricks almost every second, which means that unloading bricks can't be too slow/complex.

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'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:

Code: [Select]
$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:

Code: [Select]
$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?

Ah okay, so I figured out the problem.

The variable $LoadingBricks_BrickGroup is only not overwritten and taken into account if you use ServerLoadSaveFile_Start( <save file> ); instead of serverDirectSaveFileLoad();.

I found an old thread by Port that has all of the variables associated with the former command, in case anyone else encounters this problem.

Code: [Select]
$LoadingBricks_BrickGroup = <brick group>;
$LoadingBricks_Client = <client>;
$LoadingBricks_ColorMethod = 3;
$LoadingBricks_DirName = missionInfo.saveName;
$LoadingBricks_DoOwnership = true;
$LoadingBricks_FileName = <save file>;
$LoadingBricks_PositionOffset = "0 0 0";
$LoadingBricks_Silent = true;
$LoadingBricks_StartTime = getSimTime();
ServerLoadSaveFile_Start( <save file> );
« Last Edit: July 31, 2016, 05:38:48 PM by SeventhSandwich »

Ah okay, so I figured out the problem.

The variable $LoadingBricks_BrickGroup is only not overwritten and taken into account if you use ServerLoadSaveFile_Start( <save file> ); instead of serverDirectSaveFileLoad();.

I found an old thread by Port that has all of the variables associated with the latter command, in case anyone else encounters this problem.

Code: [Select]
$LoadingBricks_BrickGroup = <brick group>;
$LoadingBricks_Client = <client>;
$LoadingBricks_ColorMethod = 3;
$LoadingBricks_DirName = missionInfo.saveName;
$LoadingBricks_DoOwnership = true;
$LoadingBricks_FileName = <save file>;
$LoadingBricks_PositionOffset = "0 0 0";
$LoadingBricks_Silent = true;
$LoadingBricks_StartTime = getSimTime();
ServerLoadSaveFile_Start( <save file> );
can you explain further how to use these with the latter command, and/or link the topic you found? iirc serverDirectSaveFileLoad() takes in only 4 parameters: directory, colormethod, something im not sure, and ownership

can you explain further how to use these with the latter command, and/or link the topic you found? iirc serverDirectSaveFileLoad() takes in only 4 parameters: directory, colormethod, something im not sure, and ownership
serverDirectSaveFileLoad(%filename, %colorMethod, %dir, %ownership, %silent);
%dir was for maps, so now you would just use "".
« Last Edit: July 31, 2016, 09:36:17 AM by Cruxeis »

can you explain further how to use these with the latter command, and/or link the topic you found? iirc serverDirectSaveFileLoad() takes in only 4 parameters: directory, colormethod, something im not sure, and ownership
You declare those global variables and then call ServerLoadSaveFile_Start(); and it uses those settings when loading a file.

You declare those global variables and then call ServerLoadSaveFile_Start(); and it uses those settings when loading a file.
you should have said former command then, lol

kk thx