Added new blocks. and changed Drone.extend to support single param.
This commit is contained in:
parent
c324adf269
commit
2f2db3c76f
4 changed files with 34 additions and 8 deletions
|
@ -230,7 +230,9 @@ var blocks = {
|
||||||
white: 171 // All other colors added below
|
white: 171 // All other colors added below
|
||||||
},
|
},
|
||||||
hardened_clay: 172,
|
hardened_clay: 172,
|
||||||
coal_block: 173
|
coal_block: 173,
|
||||||
|
packed_ice: 174,
|
||||||
|
double_plant: 175
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add all available colors to colorized block collections
|
// Add all available colors to colorized block collections
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var bkItemStack = org.bukkit.inventory.ItemStack,
|
var bkItemStack = org.bukkit.inventory.ItemStack,
|
||||||
bkMaterial = org.bukkit.Material
|
bkMaterial = org.bukkit.Material;
|
||||||
|
|
||||||
var items = function( material, amount ) {
|
var items = function( material, amount ) {
|
||||||
material = material.toUpperCase();
|
material = material.toUpperCase();
|
||||||
return new bkItemStack(bkMaterial[material],amount);
|
return new bkItemStack(bkMaterial[material],amount);
|
||||||
|
|
|
@ -15,10 +15,16 @@ Drone.extend('temple', function(side) {
|
||||||
var middle = Math.round( (side-2) / 2 );
|
var middle = Math.round( (side-2) / 2 );
|
||||||
this.chkpt('corner')
|
this.chkpt('corner')
|
||||||
.box( stone, side, 1, side )
|
.box( stone, side, 1, side )
|
||||||
.right( middle ).box( stair ).right().box( stair )
|
.right( middle )
|
||||||
.move('corner').up().fwd().right();
|
.box( stair )
|
||||||
|
.right()
|
||||||
|
.box( stair )
|
||||||
|
.move('corner')
|
||||||
|
.up()
|
||||||
|
.fwd()
|
||||||
|
.right();
|
||||||
side = side - 2;
|
side = side - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.move('temple');
|
this.move('temple');
|
||||||
});
|
});
|
||||||
|
|
|
@ -582,10 +582,13 @@ Use this method to add new methods (which also become chainable global functions
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
* name - The name of the new method e.g. 'pyramid'
|
* name - The name of the new method e.g. 'pyramid'.
|
||||||
* function - The method body.
|
* function - The method body.
|
||||||
|
|
||||||
#### Example
|
Alternatively if you provide just a function as a parameter, then the function name will be used as the new method name. For example the following two approaches are both valid.
|
||||||
|
|
||||||
|
|
||||||
|
#### Example 1 Using name and function as parameters
|
||||||
|
|
||||||
// submitted by [edonaldson][edonaldson]
|
// submitted by [edonaldson][edonaldson]
|
||||||
Drone.extend('pyramid', function( block,height) {
|
Drone.extend('pyramid', function( block,height) {
|
||||||
|
@ -596,6 +599,16 @@ Use this method to add new methods (which also become chainable global functions
|
||||||
return this.move('pyramid');
|
return this.move('pyramid');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#### Example 2 Using just a named function as a parameter
|
||||||
|
|
||||||
|
Drone.extend(function pyramid( block,height) {
|
||||||
|
this.chkpt('pyramid');
|
||||||
|
for ( var i = height; i > 0; i -= 2) {
|
||||||
|
this.box(block, i, 1, i).up().right().fwd();
|
||||||
|
}
|
||||||
|
return this.move('pyramid');
|
||||||
|
});
|
||||||
|
|
||||||
Once the method is defined (it can be defined in a new pyramid.js file) it can be used like so...
|
Once the method is defined (it can be defined in a new pyramid.js file) it can be used like so...
|
||||||
|
|
||||||
var d = new Drone();
|
var d = new Drone();
|
||||||
|
@ -790,6 +803,10 @@ addUnloadHandler( function() {
|
||||||
// add custom methods to the Drone object using this function
|
// add custom methods to the Drone object using this function
|
||||||
//
|
//
|
||||||
Drone.extend = function( name, func ) {
|
Drone.extend = function( name, func ) {
|
||||||
|
if (arguments.length == 1){
|
||||||
|
func = name;
|
||||||
|
name = func.name;
|
||||||
|
}
|
||||||
Drone.prototype[ '_' + name ] = func;
|
Drone.prototype[ '_' + name ] = func;
|
||||||
Drone.prototype[ name ] = function( ) {
|
Drone.prototype[ name ] = function( ) {
|
||||||
if ( this.record ) {
|
if ( this.record ) {
|
||||||
|
|
Reference in a new issue