Page 1 of 1

/pillar (height)

PostPosted: 15 Jan 2014, 00:12
by Leeizazombie
Kinda like /pillareraser but it actually makes a pillar, handy for creating towers, I've never tried making building commands but I'm sure if someone can make this command, it will help me get the idea ;)!

Re: /pillar (height)

PostPosted: 15 Jan 2014, 14:28
by dzienny
Drawing command example may help you understand how to make a drawing command. It hasn't been mentioned there, but to check the block at the given coordinates you can use:
Code: Select all
byte Level.GetTile(int x, int y, int z)

Then you can check the block type, or whether it is air.
Example:
Code: Select all
// Get a block from a player's current level at x, y, z coordinates.
byte block = p.level.GetTile(x, y, z);

// Block.IsAir(byte block) returns true if a block is air or op_air; false otherwise.
bool isAir = Block.IsAir(block);

// Check if block is a grass block.
bool isGrass = block == Block.grass;

Re: /pillar (height)

PostPosted: 21 Jan 2014, 23:50
by Leeizazombie
Thank you Dzienny, it was helpful!
I was able to make it place a pillar at a set height but the problem is that I have to place two blocks to set the spot, I tried:
Code: Select all
BlockCatch.CaptureOneBlock(p, 2, DrawCuboid, new BasicDrawArgs(block));

No matter what arguments I use it keeps giving errors that the arguments are invalid, I have no idea how to make it capture one block only, can you show an example please?

Re: /pillar (height)

PostPosted: 22 Jan 2014, 02:44
by ismellike
I didn't truly familiarize myself with the new blockchange event, but I can give you some help with the old one.

Code: Select all
public override void use(Player p, string message)
{
   p.ClearBlockchange();
   p.Blockchange+=Blockchange;
}
public void Blockchange(Player p, ushort x, ushort y, ushort z, byte type)
{
   for(ushort height = y; height<=p.level.height-1; height++)
   {
       byte b = p.level.GetTile(x,height,z);
       //if checking for something {  }
       p.level.Blockchange(p,x,height,z,type);
   }
   if(!p.static)
     p.ClearBlockchange();
}


there is probably errors, but it should definitely help you

Re: /pillar (height)

PostPosted: 22 Jan 2014, 04:09
by Leeizazombie
Thank you, I'll take a look into it tomorrow!

ps: err sorry if I sent too many of the same post in Knowledge base, I tought it was not sending until I finally seen a message saying that moderators must see it first.

Re: /pillar (height)

PostPosted: 22 Jan 2014, 14:33
by dzienny
Leeizazombie wrote:Thank you Dzienny, it was helpful!
I was able to make it place a pillar at a set height but the problem is that I have to place two blocks to set the spot, I tried:
Code: Select all
BlockCatch.CaptureOneBlock(p, 2, DrawCuboid, new BasicDrawArgs(block));

No matter what arguments I use it keeps giving errors that the arguments are invalid, I have no idea how to make it capture one block only, can you show an example please?


The CaptureOneBlock method has a different signature. You can use
Code: Select all
BlockCatch.CaptureOneBlock(p, DrawPillar, new BasicDrawArgs(block));

or alternatively
Code: Select all
BlockCatch.CaptureMultipleBlocks(p, 1, DrawPillar, new BasicDrawArgs(block));

where 1 is the number of blocks to capture.

If you use the first option then your callback method has to be:
Code: Select all
void DrawPillar(Player p, ChangeInfo change, BasicDrawArgs args) { }

If you use CaptureMultipleBlocks then the callback method signature is:
Code: Select all
void DrawPillar(Player p, List<ChangeInfo> changes, BasicDrawArgs args) { }


Of course if you use CaptureMultipleBlocks with the argument of blocks to catch equal to 1, then the list of changes will contain exactly one element.

Re: /pillar (height)

PostPosted: 22 Jan 2014, 15:02
by Leeizazombie
Ah, I see what I done wrong, thanks for your help!

Re: /pillar (height)

PostPosted: 20 May 2014, 08:58
by tommyz_
Hey man here ya go: viewtopic.php?f=19&t=2862
Made it for ya, the easy way! :D