Drone.garden() is now non-destructive - won't destroy existing blocks.
This commit is contained in:
parent
ef02885613
commit
d976563adf
4 changed files with 139 additions and 49 deletions
|
@ -86,7 +86,9 @@ Walter Higgins
|
||||||
* [Drone.cylinder0() method](#dronecylinder0-method)
|
* [Drone.cylinder0() method](#dronecylinder0-method)
|
||||||
* [Drone.arc() method](#dronearc-method)
|
* [Drone.arc() method](#dronearc-method)
|
||||||
* [Drone.door() method](#dronedoor-method)
|
* [Drone.door() method](#dronedoor-method)
|
||||||
|
* [Drone.door_iron() method](#dronedoor_iron-method)
|
||||||
* [Drone.door2() method](#dronedoor2-method)
|
* [Drone.door2() method](#dronedoor2-method)
|
||||||
|
* [Drone.door2_iron() method](#dronedoor2_iron-method)
|
||||||
* [Drone.sign() method](#dronesign-method)
|
* [Drone.sign() method](#dronesign-method)
|
||||||
* [Drone Trees methods](#drone-trees-methods)
|
* [Drone Trees methods](#drone-trees-methods)
|
||||||
* [Drone.garden() method](#dronegarden-method)
|
* [Drone.garden() method](#dronegarden-method)
|
||||||
|
@ -1761,6 +1763,10 @@ To create an iron door...
|
||||||
|
|
||||||
![iron door](img/doorex1.png)
|
![iron door](img/doorex1.png)
|
||||||
|
|
||||||
|
### Drone.door_iron() method
|
||||||
|
|
||||||
|
create an Iron door.
|
||||||
|
|
||||||
### Drone.door2() method
|
### Drone.door2() method
|
||||||
|
|
||||||
Create double doors (left and right side)
|
Create double doors (left and right side)
|
||||||
|
@ -1777,6 +1783,11 @@ To create double-doors at the cross-hairs/drone's location...
|
||||||
|
|
||||||
![double doors](img/door2ex1.png)
|
![double doors](img/door2ex1.png)
|
||||||
|
|
||||||
|
### Drone.door2_iron() method
|
||||||
|
|
||||||
|
Create double iron doors
|
||||||
|
|
||||||
|
|
||||||
### Drone.sign() method
|
### Drone.sign() method
|
||||||
|
|
||||||
Signs must use block 63 (stand-alone signs) or 68 (signs on walls)
|
Signs must use block 63 (stand-alone signs) or 68 (signs on walls)
|
||||||
|
@ -1854,7 +1865,12 @@ place random blocks stone, mossy stone and cracked stone (each block has the sam
|
||||||
|
|
||||||
to place random blocks stone has a 50% chance of being picked,
|
to place random blocks stone has a 50% chance of being picked,
|
||||||
|
|
||||||
rand({blocks.brick.stone: 5, blocks.brick.mossy: 3, blocks.brick.cracked: 2},w,d,h)
|
var distribution = {};
|
||||||
|
distribution[ blocks.brick.stone ] = 5;
|
||||||
|
distribution[ blocks.brick.mossy ] = 3;
|
||||||
|
distribution[ blocks.brick.cracked ] = 2;
|
||||||
|
|
||||||
|
rand( distribution, width, height, depth)
|
||||||
|
|
||||||
regular stone has a 50% chance, mossy stone has a 30% chance and cracked stone has just a 20% chance of being picked.
|
regular stone has a 50% chance, mossy stone has a 30% chance and cracked stone has just a 20% chance of being picked.
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@ var Drone = require('../drone').Drone;
|
||||||
// constructs a medieval fort
|
// constructs a medieval fort
|
||||||
//
|
//
|
||||||
Drone.extend('fort', function( side, height ) {
|
Drone.extend('fort', function( side, height ) {
|
||||||
|
var brick = 98,
|
||||||
|
turret,
|
||||||
|
i,
|
||||||
|
torch,
|
||||||
|
ladder;
|
||||||
|
|
||||||
if ( typeof side == 'undefined' ) {
|
if ( typeof side == 'undefined' ) {
|
||||||
side = 18;
|
side = 18;
|
||||||
}
|
}
|
||||||
|
@ -21,53 +27,65 @@ Drone.extend('fort', function( side, height ) {
|
||||||
if ( height < 4 || side < 10 ) {
|
if ( height < 4 || side < 10 ) {
|
||||||
throw new java.lang.RuntimeException('Forts must be at least 10 wide X 4 tall');
|
throw new java.lang.RuntimeException('Forts must be at least 10 wide X 4 tall');
|
||||||
}
|
}
|
||||||
var brick = 98;
|
|
||||||
//
|
//
|
||||||
// build walls.
|
// build walls.
|
||||||
//
|
//
|
||||||
this.chkpt('fort').box0(brick,side,height-1,side);
|
this.chkpt('fort')
|
||||||
|
.box0(brick,side,height-1,side)
|
||||||
|
.up(height-1);
|
||||||
//
|
//
|
||||||
// build battlements
|
// build battlements
|
||||||
//
|
//
|
||||||
this.up(height-1);
|
|
||||||
for ( i = 0; i <= 3; i++ ) {
|
for ( i = 0; i <= 3; i++ ) {
|
||||||
var turret = [];
|
|
||||||
|
turret = [
|
||||||
|
'109:'+ Drone.PLAYER_STAIRS_FACING[this.dir],
|
||||||
|
'109:'+ Drone.PLAYER_STAIRS_FACING[(this.dir+2)%4]
|
||||||
|
];
|
||||||
this.box(brick) // solid brick corners
|
this.box(brick) // solid brick corners
|
||||||
.up().box('50:5').down() // light a torch on each corner
|
.up()
|
||||||
.fwd();
|
.box('50:5')
|
||||||
turret.push('109:'+ Drone.PLAYER_STAIRS_FACING[this.dir]);
|
.down() // light a torch on each corner
|
||||||
turret.push('109:'+ Drone.PLAYER_STAIRS_FACING[(this.dir+2)%4]);
|
.fwd()
|
||||||
try {
|
.boxa(turret,1,1,side-2)
|
||||||
this.boxa(turret,1,1,side-2).fwd(side-2).turn();
|
.fwd(side-2)
|
||||||
} catch( e ) {
|
.turn();
|
||||||
console.log('ERROR: ' + e.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// build battlement's floor
|
// build battlement's floor
|
||||||
//
|
//
|
||||||
this.move('fort');
|
this.move('fort')
|
||||||
this.up(height-2).fwd().right();
|
.up(height-2)
|
||||||
for ( var i = 0; i < battlementWidth; i++ ) {
|
.fwd()
|
||||||
this.box0('126:0', side - ( 2 + (i * 2) ), 1, side - ( 2 + ( i * 2) ));
|
.right();
|
||||||
this.fwd().right();
|
|
||||||
|
for ( i = 0; i < battlementWidth; i++ ) {
|
||||||
|
|
||||||
|
this.box0('126:0', side - ( 2 + (i * 2) ), 1, side - ( 2 + ( i * 2) ))
|
||||||
|
.fwd()
|
||||||
|
.right();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// add door
|
// add door
|
||||||
//
|
//
|
||||||
var torch = '50:' + Drone.PLAYER_TORCH_FACING[this.dir];
|
torch = '50:' + Drone.PLAYER_TORCH_FACING[this.dir];
|
||||||
this.move('fort').right((side/2)-1).door2() // double doors
|
this.move('fort')
|
||||||
.back().left().up()
|
.right((side/2)-1)
|
||||||
|
.door2() // double doors
|
||||||
|
.back()
|
||||||
|
.left()
|
||||||
|
.up()
|
||||||
.box(torch) // left torch
|
.box(torch) // left torch
|
||||||
.right(3)
|
.right(3)
|
||||||
.box(torch); // right torch
|
.box(torch); // right torch
|
||||||
//
|
//
|
||||||
// add ladder up to battlements
|
// add ladder up to battlements
|
||||||
//
|
//
|
||||||
var ladder = '65:' + Drone.PLAYER_SIGN_FACING[(this.dir+2)%4];
|
ladder = '65:' + Drone.PLAYER_SIGN_FACING[(this.dir+2)%4];
|
||||||
this.move('fort').right((side/2)-3).fwd(1) // move inside fort
|
this.move('fort')
|
||||||
.box(ladder, 1,height-1,1);
|
.right((side/2)-3)
|
||||||
return this.move('fort');
|
.fwd(1) // move inside fort
|
||||||
|
.box(ladder, 1,height-1,1)
|
||||||
|
.move('fort');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@ Drone.extend('hangtorch', function () {
|
||||||
this.back();
|
this.back();
|
||||||
if (moves == 10){
|
if (moves == 10){
|
||||||
this.fwd(moves);
|
this.fwd(moves);
|
||||||
console.log('no air to hang torch');
|
console.log('nowhere to hang torch');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
block = this.world.getBlockAt(this.x, this.y, this.z);
|
block = this.world.getBlockAt(this.x, this.y, this.z);
|
||||||
}
|
}
|
||||||
this.box(torch);
|
this.box(torch)
|
||||||
this.fwd(moves);
|
.fwd(moves);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,8 +3,8 @@ var utils = require('utils'),
|
||||||
Location = org.bukkit.Location,
|
Location = org.bukkit.Location,
|
||||||
Player = org.bukkit.entity.Player,
|
Player = org.bukkit.entity.Player,
|
||||||
Sign = org.bukkit.block.Sign,
|
Sign = org.bukkit.block.Sign,
|
||||||
TreeType = org.bukkit.TreeType;
|
TreeType = org.bukkit.TreeType,
|
||||||
|
Material = org.bukkit.Material;
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
## Drone Plugin
|
## Drone Plugin
|
||||||
|
|
||||||
|
@ -388,6 +388,10 @@ To create an iron door...
|
||||||
|
|
||||||
![iron door](img/doorex1.png)
|
![iron door](img/doorex1.png)
|
||||||
|
|
||||||
|
### Drone.door_iron() method
|
||||||
|
|
||||||
|
create an Iron door.
|
||||||
|
|
||||||
### Drone.door2() method
|
### Drone.door2() method
|
||||||
|
|
||||||
Create double doors (left and right side)
|
Create double doors (left and right side)
|
||||||
|
@ -404,6 +408,11 @@ To create double-doors at the cross-hairs/drone's location...
|
||||||
|
|
||||||
![double doors](img/door2ex1.png)
|
![double doors](img/door2ex1.png)
|
||||||
|
|
||||||
|
### Drone.door2_iron() method
|
||||||
|
|
||||||
|
Create double iron doors
|
||||||
|
|
||||||
|
|
||||||
### Drone.sign() method
|
### Drone.sign() method
|
||||||
|
|
||||||
Signs must use block 63 (stand-alone signs) or 68 (signs on walls)
|
Signs must use block 63 (stand-alone signs) or 68 (signs on walls)
|
||||||
|
@ -481,7 +490,12 @@ place random blocks stone, mossy stone and cracked stone (each block has the sam
|
||||||
|
|
||||||
to place random blocks stone has a 50% chance of being picked,
|
to place random blocks stone has a 50% chance of being picked,
|
||||||
|
|
||||||
rand({blocks.brick.stone: 5, blocks.brick.mossy: 3, blocks.brick.cracked: 2},w,d,h)
|
var distribution = {};
|
||||||
|
distribution[ blocks.brick.stone ] = 5;
|
||||||
|
distribution[ blocks.brick.mossy ] = 3;
|
||||||
|
distribution[ blocks.brick.cracked ] = 2;
|
||||||
|
|
||||||
|
rand( distribution, width, height, depth)
|
||||||
|
|
||||||
regular stone has a 50% chance, mossy stone has a 30% chance and cracked stone has just a 20% chance of being picked.
|
regular stone has a 50% chance, mossy stone has a 30% chance and cracked stone has just a 20% chance of being picked.
|
||||||
|
|
||||||
|
@ -995,7 +1009,11 @@ Drone.extend( 'sign', function( message, block ) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Drone.prototype.cuboida = function(/* Array */ blocks, w, h, d ) {
|
Drone.prototype.cuboida = function(/* Array */ blocks, w, h, d, overwrite ) {
|
||||||
|
|
||||||
|
if ( typeof overwrite == 'undefined' ) {
|
||||||
|
overwrite = true;
|
||||||
|
}
|
||||||
var properBlocks = [];
|
var properBlocks = [];
|
||||||
var len = blocks.length;
|
var len = blocks.length;
|
||||||
for ( var i = 0; i < len; i++ ) {
|
for ( var i = 0; i < len; i++ ) {
|
||||||
|
@ -1022,7 +1040,9 @@ Drone.prototype.cuboida = function(/* Array */ blocks, w, h, d ) {
|
||||||
_traverse[dir].width( that, w, function( ) {
|
_traverse[dir].width( that, w, function( ) {
|
||||||
var block = that.world.getBlockAt( that.x, that.y, that.z );
|
var block = that.world.getBlockAt( that.x, that.y, that.z );
|
||||||
var properBlock = properBlocks[ bi % len ];
|
var properBlock = properBlocks[ bi % len ];
|
||||||
|
if (overwrite || block.type.equals(Material.AIR) ) {
|
||||||
block.setTypeIdAndData( properBlock[0], properBlock[1], false );
|
block.setTypeIdAndData( properBlock[0], properBlock[1], false );
|
||||||
|
}
|
||||||
bi++;
|
bi++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1107,6 +1127,14 @@ Drone.extend( 'door', function( door ) {
|
||||||
.down( );
|
.down( );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Drone.extend( 'door_iron', function( ) {
|
||||||
|
var door = 71;
|
||||||
|
this.cuboidX( door, this.dir )
|
||||||
|
.up( )
|
||||||
|
.cuboidX( door, 8 )
|
||||||
|
.down( );
|
||||||
|
} );
|
||||||
|
|
||||||
Drone.extend( 'door2' , function( door ) {
|
Drone.extend( 'door2' , function( door ) {
|
||||||
if ( typeof door == 'undefined' ) {
|
if ( typeof door == 'undefined' ) {
|
||||||
door = 64;
|
door = 64;
|
||||||
|
@ -1119,6 +1147,15 @@ Drone.extend( 'door2' , function( door ) {
|
||||||
.cuboidX( door, 9 ).down( )
|
.cuboidX( door, 9 ).down( )
|
||||||
.cuboidX( door, this.dir ).left( );
|
.cuboidX( door, this.dir ).left( );
|
||||||
} );
|
} );
|
||||||
|
Drone.extend( 'door2_iron' , function( door ) {
|
||||||
|
var door = 71;
|
||||||
|
this
|
||||||
|
.cuboidX( door, this.dir ).up( )
|
||||||
|
.cuboidX( door, 8 ).right( )
|
||||||
|
.cuboidX( door, 9 ).down( )
|
||||||
|
.cuboidX( door, this.dir ).left( );
|
||||||
|
} );
|
||||||
|
|
||||||
// player dirs: 0 = east, 1 = south, 2 = west, 3 = north
|
// player dirs: 0 = east, 1 = south, 2 = west, 3 = north
|
||||||
// block dirs: 0 = east, 1 = west, 2 = south , 3 = north
|
// block dirs: 0 = east, 1 = west, 2 = south , 3 = north
|
||||||
// sign dirs: 5 = east, 3 = south, 4 = west, 2 = north
|
// sign dirs: 5 = east, 3 = south, 4 = west, 2 = north
|
||||||
|
@ -1712,18 +1749,32 @@ var _copy = function( name, w, h, d ) {
|
||||||
} );
|
} );
|
||||||
Drone.clipBoard[name] = {dir: this.dir, blocks: ccContent};
|
Drone.clipBoard[name] = {dir: this.dir, blocks: ccContent};
|
||||||
};
|
};
|
||||||
var _garden = function( w,d ) {
|
var _garden = function( width, depth ) {
|
||||||
|
if ( typeof width == 'undefined' ) {
|
||||||
|
width = 10;
|
||||||
|
}
|
||||||
|
if ( typeof depth == 'undefined' ) {
|
||||||
|
depth = width;
|
||||||
|
}
|
||||||
|
var grass = 2,
|
||||||
|
red = 37,
|
||||||
|
yellow = 38,
|
||||||
|
longgrass = '31:1',
|
||||||
|
air = 0;
|
||||||
|
|
||||||
// make sure grass is present first
|
// make sure grass is present first
|
||||||
this.down( ).box(2,w,1,d ).up( );
|
this.down()
|
||||||
|
.box( grass, width, 1, depth )
|
||||||
|
.up( );
|
||||||
|
|
||||||
// make flowers more common than long grass
|
// make flowers more common than long grass
|
||||||
var dist = {37: 3, // red flower
|
var dist = { };
|
||||||
38: 3, // yellow flower
|
dist[red] = 3;
|
||||||
'31:1': 2, // long grass
|
dist[yellow] = 3;
|
||||||
0: 1
|
dist[longgrass] = 2;
|
||||||
};
|
dist[air] = 1;
|
||||||
|
|
||||||
return this.rand(dist,w,1,d );
|
return this.rand( dist, width, 1, depth, false /* don't overwrite */ );
|
||||||
};
|
};
|
||||||
|
|
||||||
var _rand = function( blockDistribution ) {
|
var _rand = function( blockDistribution ) {
|
||||||
|
@ -1744,10 +1795,15 @@ var _rand = function( blockDistribution ) {
|
||||||
_fisherYates(blockDistribution );
|
_fisherYates(blockDistribution );
|
||||||
return blockDistribution;
|
return blockDistribution;
|
||||||
};
|
};
|
||||||
Drone.extend('rand',function( dist,w,h,d ) {
|
|
||||||
var randomized = _rand(dist );
|
Drone.extend( 'rand', function( dist, width, height, depth, overwrite ) {
|
||||||
this.boxa(randomized,w,h,d );
|
if ( typeof overwrite == 'undefined' ) {
|
||||||
|
overwrite = true;
|
||||||
|
}
|
||||||
|
var randomized = _rand( dist );
|
||||||
|
this.boxa( randomized, width, height, depth, overwrite);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
var _trees = {
|
var _trees = {
|
||||||
oak: TreeType.BIG_TREE ,
|
oak: TreeType.BIG_TREE ,
|
||||||
birch: TreeType.BIRCH ,
|
birch: TreeType.BIRCH ,
|
||||||
|
|
Reference in a new issue