Author Topic: Saving Bricks  (Read 1147 times)

This works but freezes on huge builds. Just wondering if anybody could make use of it and/or edit it.

Code: [Select]
datablock itemData(decollideItem)
{
category = "";
className = "";

shapeFile = "base/data/shapes/empty.dts";
mass = 1;
density = 1;
elasticity = 1;
friction = 1;
emap = true;

uiName = "Decollide";
iconName = "";
doColorShift = true;
colorShiftColor = "1 1 1 1";

canDrop = true;
};

function decollideItem::onPickup(%this)
{
return;
}

function decollideItem::onAdd(%this, %object, %continue)
{
if(%continue !$= "true")
{
%this.schedule(100, "onAdd", %this, %object, true);

return;
}

for(%a = 0; %a < mainBrickGroup.getCount(); %a++)
{
for(%b = 0; %b < mainBrickGroup.getObject(%a).getCount(); %b++)
{
if(mainBrickGroup.getObject(%a).getObject(%b).item == %object)
{
mainBrickGroup.getObject(%a).getObject(%b).setColliding(true);
}
}
}
}

function decollideItem::onRemove(%this, %object)
{
if(%continue !$= "true")
{
%this.schedule(100, "onRemove", %this, %object, true);

return;
}

for(%a = 0; %a < mainBrickGroup.getCount(); %a++)
{
for(%b = 0; %b < mainBrickGroup.getObject(%a).getCount(); %b++)
{
if(mainBrickGroup.getObject(%a).getObject(%b).item == %object)
{
mainBrickGroup.getObject(%a).getObject(%b).setColliding(false);
}
}
}
}

Code: [Select]
datablock itemData(decollideItem)
{
category = "";
className = "";

shapeFile = "base/data/shapes/empty.dts";
mass = 1;
density = 1;
elasticity = 1;
friction = 1;
emap = true;

uiName = "Decollide";
iconName = "";
doColorShift = true;
colorShiftColor = "1 1 1 1";

canDrop = true;
};

function decollideItem::onPickup(%this)
{
return;
}

function decollideItem::onAdd(%this, %item)
{
 Parent::onAdd(%this,%item);
 schedule(100,0,decolcheck,%item,0);
}

function decollideItem::onRemove(%this, %item)
{
 Parent::onAdd(%this,%item);
 schedule(100,0,decolcheck,%item,1);
}

function decolcheck(%item,%on)
{
 %item.spawnbrick.setColliding(%on);
}

Why are you setting colliding to "True" as the item is spawned? Wouldn't it work better if it was made not colliding as you spawn a "Decollide"?

Yes but that defeats the purpose of it loading/saving with blb files.

It does load. That's almost exactly the same as the code I used in the Trap Bricks, which save and load except for the Trigger's variables which are different.