Author Topic: Floating Brick Script  (Read 1009 times)

I'm having a problem with the following script; bricks that are loaded and are supporting other bricks cannot be destroyed else the entire build collapses. How can I make this remove brick support when the package is activated or bricks are loaded?

Code: [Select]
if(isPackage(floatingBricks))
deactivatepackage(floatingBricks);

package floatingBricks
{
function serverCmdPlantBrick(%client)
{
if(!isObject(%client.player))
return;
%ghost = %client.player.tempBrick;
if(!isObject(%ghost))
return;
%brick = new fxDTSBrick()
{
position = %ghost.getPosition();
datablock = %ghost.getDatablock().getName();
rotation = %ghost.rotation;
angleID = %ghost.angleID;
colorID = %ghost.colorID;
client = %client;
isPlanted = 1;
scale = %ghost.scale;
stackBL_ID = %client.bl_id;
printID = %ghost.printID;
};
%brick.setTrusted( true );
%plant = %brick.plant();
if(%plant != 0 && %plant != 2)
{
%brick.delete();
}
else
{
if(%plant == 2)
{
%brick.floatingHammer = true;
}
%group = "BrickGroup_" @ %client.bl_id;
if(!isObject(%group))
{
%set = new SimSet()
{
bl_id = %client.bl_id;
client = %client;
};
%set.setName(%group);
mainBrickGroup.add(%set);
}
%group.add(%brick);
}
}
function hammerimage::onHitObject(%this, %obj, %slot, %col, %d,%e,%f)
{
if(%col.getClassName() $= "fxDTSBrick")
{
if(%col.floatingHammer)
{
if(getTrustLevel(%col,%cl = %obj.client) == 0)
{
messageClient(%cl,'',%cl.name @ " does not trust you enough to do that.");
return;
}
else
{
%col.delete();
}
}
else
{
return parent::onHitObject(%this,%obj,%slot,%col,%d,%e,%f);
}
}
else
return parent::onHitObject(%this,%obj,%slot,%col,%d,%e,%f);
}
};activatepackage(floatingBricks);

If you just want to prevent bricks from causing a chain reaction, you can do this:

Code: [Select]
package noChains {
    function fxDTSBrick::killBrick(%this)
    {
        if(%this.willCauseChainKill())
        {
            %this.delete();
            return;
        }
        parent::killBrick(%this);
    }
};
activatePackage(noChains);

That's good but what about making supportive bricks destructible? That's my main problem.

I don't see what you mean. Supportive bricks are not "indestructable" except by the hammer, and it appears you fixed that in your package of the hammer.

Figured out the problem- the destructo wand is the only thing that works. Thanks for the help!