Author Topic: Spawning new bricks = multiple problems?  (Read 995 times)

package MinifigBrick
{
function fxDTSbrick::PlantedTrustCheck(%brick)
{
Parent::PlantedTrustCheck(%brick);

if(%brick.GetDatablock().getName() $= brickMinifigV2Data)
{
%pos = %brick.position;

%rot = %brick.rotation;

%brick.delete();

new fxDTSbrick()
{
  datablock = "brickLeftShoeData";
  isPlanted = 1;
  position = %pos;
  rotation = %rot;
  isTrusted = 1;
};

new fxDTSbrick()
{
  datablock = "brickRightShoeData";
  isPlanted = 1;
  position = %pos;
  rotation = %rot;
  isTrusted = 1;
};
}
}
};

ActivatePackage(MinifigBrick);

This is the code I am using for my upcoming minifig brick, uses the whole brick as a template, then deletes the template and plants each body part seperatly after spawning for decal/paint customization

the bricks spawn, they just render and thats it, they don't have any collision, you can't target them with /getId, you can't clear them and they don't appear to count as bricks

yes they are meant to be planted in themselves, I know what I'm doing
« Last Edit: December 09, 2011, 03:58:48 PM by soba »

Code: [Select]
function CreateBrick(%data, %pos, %angleID, %color, %owner, %colorFx, %shapeFx)
{
%brick = new FxDTSbrick()
{
datablock = %data;
position = %pos;
rotation = "0 0 1 " @ %angleID * 90;
colorID = %color;
scale = "1 1 1";
angleID = %angleID;
colorFxID = %colorFx;
shapeFxID = %shapeFx;
isPlanted = 1;
isBaseplate = 1;
client = %owner;
};
%brick.setTrusted(1);
%brick.plant();
if(%owner.brickGroup)
{
%owner.brickGroup.add(%brick);
}
$Server::BrickCount++;
return %brick;
}

Code: (Original) [Select]
new fxDTSbrick()
{
  datablock = "brickLeftShoeData";
  isPlanted = 1;
  position = %pos;
  rotation = %rot;
  isTrusted = 1;
};

Code: [Select]
%obj = new fxDTSBrick()
{
    datablock = "brickLeftShoeData";
    position = %pos;
    rotation = %rot;
    isPlanted = true;
};

%obj.setTrusted(true);
%obj.plant();
if(isObject(%group = %brick.getGroup()))
    %group.add(%obj);



EDIT: Damn it. :V
« Last Edit: December 09, 2011, 05:43:46 PM by Port »

I'm trying to spawn multiple bricks, and if one brick is already parented to %brick, would multiple %brick = new fxDTSbrick's replace it?

function CreateBrick(%data, %pos, %angleID, %color, %owner, %colorFx, %shapeFx)
{
   %brick = new FxDTSbrick()
   {
      datablock = %data;
      position = %pos;
      rotation = "0 0 1 " @ %angleID * 90;
      colorID = %color;
      scale = "1 1 1";
      angleID = %angleID;
      colorFxID = %colorFx;
      shapeFxID = %shapeFx;
      isPlanted = 1;
      isBaseplate = 1;
      client = %owner;
   };
   %brick.setTrusted(1);
   %brick.plant();
   if(%owner.brickGroup)
   {
      %owner.brickGroup.add(%brick);
   }
   $Server::BrickCount++;
   return %brick;
}
Remove the $Server::BrickCount++, %brick.plant does that automatically as far as ive seen, resulting in double the brickcount then there should be.
Also, is there any way to prevent a brick from being placed in the same spot through script? I've been working on that problem but I cant figure it out.

Remove the $Server::BrickCount++, %brick.plant does that automatically as far as ive seen, resulting in double the brickcount then there should be.
I just checked and this is correct, that line should indeed not be there.

Also, is there any way to prevent a brick from being placed in the same spot through script? I've been working on that problem but I cant figure it out.
Try checking the return of %brick.plant();, I think it will give error codes depending on what's wrong

Also, is there any way to prevent a brick from being placed in the same spot through script? I've been working on that problem but I cant figure it out.
You mean when planting the brick, it doesen't plant it in the spot its temp brick spawns it in?
nvm

I can't ctrl+z the bricks once they are planted :(
« Last Edit: December 09, 2011, 04:44:56 PM by soba »

You mean when planting the brick, it doesen't plant it in the spot its temp brick spawns it in?
nvm

I can't ctrl+z the bricks once they are planted :(
%client.undostack.push(%brick TAB "Plant");
This is the easy way, but will cause undo commands to break each brick one at a time.

%client.undostack.push(%brick TAB "Plant");
This is the easy way, but will cause undo commands to break each brick one at a time.
I wish for the whole minifig brick to get rid of all its body parts upon broken, if possible

also, only the left foot plants now

package MinifigBrick
{
function fxDTSbrick::PlantedTrustCheck(%brick)
{
Parent::PlantedTrustCheck(%brick);

if(%brick.GetDatablock().getName() $= brickMinifigV2Data)
{
%pos = %brick.position;

%rot = %brick.rotation;

%colorID = %brick.colorID;

%owner = %brick.client;

%brick.delete();

%LeftShoe = new fxDTSbrick()
{
  datablock = "brickLeftShoeData";
  isPlanted = 1;
  position = %pos;
  rotation = %rot;
  colorID = %colorID;
  client = %owner;
};

   %LeftShoe.setTrusted(1);
   %LeftShoe.plant();
   if(%owner.brickGroup)
   {
      %owner.brickGroup.add(%LeftShoe);
   }
   return %LeftShoe;

%RightShoe = new fxDTSbrick()
{
  datablock = "brickRightShoeData";
  isPlanted = 1;
  position = %pos;
  rotation = %rot;
  colorID = %colorID;
  client = %owner;
};

   %RightShoe.setTrusted(1);
   %RightShoe.plant();
   if(%owner.brickGroup)
   {
      %owner.brickGroup.add(%RightShoe);
   }
   return %RightShoe;
}
}
};

ActivatePackage(MinifigBrick);

I know that a % variable is replaced really easily, so I tried duplicating what the left shoe used and having it plant the right shoe with a different variable for each brick, no luck
« Last Edit: December 09, 2011, 04:56:53 PM by soba »

Take out the return lines, those will stop the function.

Take out the return lines, those will stop the function.
Haha, I figured, but take out both returns? or just the top one
nvm, thanks for all the help you guys
« Last Edit: December 09, 2011, 05:43:05 PM by soba »