Author Topic: placeBrick script.  (Read 1571 times)

I'm making a script on placing a brick using only scripting.
Ok so this is my script here, tell me if there's anything wrong.

function wplantbrick(brick2x4data, -88 36 0.6, 0, 0){
if(isObject(brick2x4data)){
if(-88 36 0.3) {
%b=new fxDTSbrick()
{
client=findclientbyname(I have not);
dataBlock=brick2x4data;
position=-88 36 0.6;
rotation="0 0 0 0";
scale="1 1 1";
colorID=0;
colorFXID=0;
printid="";
};
%b.setTrusted(1);
%b.plant();
if(%b.isplanted){
fcbn(I have not).brickGroup.add(%b);
}
else
{
%b.delete();
echo("Failed to plant!");
}
}
}
//Adding in all the extra brackets you forgot.}
//I use EditRocket for my scripting, but I don't know about you.

it doesn't make that much sense overall
i basically just rewrote it.

Code: [Select]
function wplantbrick(%datablock, %pos, %colorID, %colorFXID, %player)
{
if(isObject(%datablock))
{
%b=new fxDTSbrick()
{
client=findclientbyname(%player);
dataBlock=brick2x4data;
position=-%pos;
rotation="0 0 0 0";
scale="1 1 1";
colorID=%colorID;
colorFXID=%colorFXID;
printid="";
};
%b.setTrusted(1);
%b.plant();
if(%b.isplanted)
{
fcbn(%player).brickGroup.add(%b);
}
else
{
%b.delete();
echo("Failed to plant!");
}
}
}

wplantbrick("brick2x4Data", "-88 36 0.6", 0, 0, "I have not");

IMHO, neither of those functions make any sense. I've been meaning to get this code out there for a while but I'm laaazeee :c

Code: ("Create Brick") [Select]
function createBrick(%cl, %data, %pos, %color, %angleID)
{

   //This function was made by Xalos.
   //Its purpose is to create a brick owned by a player on which they are able to build.

   if(!isObject(%data) || %data.getClassName() !$= "fxDTSBrickData")
      return -1;
   if(getWordCount(%pos) != 3)
      return -1;
   if(%angleID $= "")
      %angleID = 0;
   if(isObject(%cl) && (%cl.getClassName() $= "GameConnection" | %cl.getClassName() $= "AIConnection"))
   {
      %blid = %cl.bl_id;
      if(%blid $= "")
         %blid = -1;
      %flag = 1;
   }
   else if(isObject(%cl) && %cl.getClassName() $= "SimGroup" && MainBrickgroup.isMember(%cl))
      %group = %cl;
   else
      %cl = 0;
   switch(%angleID)
   {
      case 0:
         %rot = "1 0 0 0";
      case 1:
         %rot = "0 0 1 90";
      case 2:
         %rot = "0 0 1 180";
      case 3:
         %rot = "0 0 -1 90";
   }
   (%brick = new fxDtsBrick()
   {
      client = %cl;
      colorFxID = 0;
      colorID = %color;
      datablock = %data;
      isPlanted = 1;
      position = getWord(%pos, 0) SPC getWord(%pos, 1) SPC getWord(%pos, 2);
      rotation = %rot;
      shapeFxID = 0;
      stackBL_ID = %blid;
   }).angleID = %angleID;
   %err = %brick.plant();
   %brick.setTrusted(1);
   missionCleanup.add(%brick);
   if(%flag)
      %cl.brickgroup.add(%brick);
   else if(isObject(%group))
      %group.add(%brick);
   return %brick TAB %err;
}

createBrick(findClientByName(Xal), brick2x4Data, "0 0 4", 5, 1);


It does have some bugs. For example, it doesn't trigger onPlant correctly and I don't know why, so anything that actually uses that messes up. So you can't use this for JVS or water bricks, at least not easily.

IMHO, neither of those functions make any sense. I've been meaning to get this code out there for a while but I'm laaazeee :c

Code: ("Create Brick") [Select]
function createBrick(%cl, %data, %pos, %color, %angleID)
{

   //This function was made by Xalos.
   //Its purpose is to create a brick owned by a player on which they are able to build.

   if(!isObject(%data) || %data.getClassName() !$= "fxDTSBrickData")
      return -1;
   if(getWordCount(%pos) != 3)
      return -1;
   if(%angleID $= "")
      %angleID = 0;
   if(isObject(%cl) && (%cl.getClassName() $= "GameConnection" | %cl.getClassName() $= "AIConnection"))
   {
      %blid = %cl.bl_id;
      if(%blid $= "")
         %blid = -1;
      %flag = 1;
   }
   else if(isObject(%cl) && %cl.getClassName() $= "SimGroup" && MainBrickgroup.isMember(%cl))
      %group = %cl;
   else
      %cl = 0;
   switch(%angleID)
   {
      case 0:
         %rot = "1 0 0 0";
      case 1:
         %rot = "0 0 1 90";
      case 2:
         %rot = "0 0 1 180";
      case 3:
         %rot = "0 0 -1 90";
   }
   (%brick = new fxDtsBrick()
   {
      client = %cl;
      colorFxID = 0;
      colorID = %color;
      datablock = %data;
      isPlanted = 1;
      position = getWord(%pos, 0) SPC getWord(%pos, 1) SPC getWord(%pos, 2);
      rotation = %rot;
      shapeFxID = 0;
      stackBL_ID = %blid;
   }).angleID = %angleID;
   %err = %brick.plant();
   %brick.setTrusted(1);
   missionCleanup.add(%brick);
   if(%flag)
      %cl.brickgroup.add(%brick);
   else if(isObject(%group))
      %group.add(%brick);
   return %brick TAB %err;
}

createBrick(findClientByName(Xal), brick2x4Data, "0 0 4", 5, 1);


It does have some bugs. For example, it doesn't trigger onPlant correctly and I don't know why, so anything that actually uses that messes up. So you can't use this for JVS or water bricks, at least not easily.

That's harder for me to understand than either of these, I just need to see if there are any glitches in it.

That's harder for me to understand than either of these, I just need to see if there are any glitches in it.
Worry about 'glitches' once you have something that actually executes. There are so many things preventing that from executing that I don't feel like going through them all.

That's harder for me to understand than either of these, I just need to see if there are any glitches in it.
I fixed your code so it'd actually work.

You were apparently trying to have preset arguments, why even have the arguments if they're all the same?

You tried to see if the position "-88 36 0.6" was true. What?

You tried to see if the position "-88 36 0.6" was true. What?
He actually only put the numbers in an if statement.

That's like telling the console "Plant a brick if -88 36 0.6"
It makes no sense.

I sent him the code from a procedural generation thing and didn't explain it.