Blockland Forums > Modification Help
placeBrick script.
(1/2) > >>
I-have-not:
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.
otto-san:
it doesn't make that much sense overall
i basically just rewrote it.


--- Code: ---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!");
}
}
}
--- End code ---

wplantbrick("brick2x4Data", "-88 36 0.6", 0, 0, "I have not");
Xalos:
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") ---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;
}

--- End code ---

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.
I-have-not:

--- Quote from: Xalos on August 02, 2011, 04:06:16 AM ---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") ---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;
}

--- End code ---

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.

--- End quote ---

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

--- Quote from: I-have-not on August 02, 2011, 01:25:21 PM ---That's harder for me to understand than either of these, I just need to see if there are any glitches in it.

--- End quote ---
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.
Navigation
Message Index
Next page

Go to full version